-
Notifications
You must be signed in to change notification settings - Fork 107
Description
Inital issue is here: lightninglabs/taproot-assets#1770
There is a problem of Fee-Estimation in LND when using Overlay channels which need to be fixed probably on the LND side however I open it here because this is the program which suffers from it.
Weight estimation in fee bumper doesn't account for extra change output, causing weight discrepancy and potentially not publishing the sweep transacstion
Description
The weight estimation in the fee bumper (sweep/fee_bumper.go
) is missing the extra change output when calculating transaction weight
Steps to Reproduce
- Create a sweep transaction that requires an extra change output
- Use the fee bumper to estimate transaction weight
- Compare estimated weight with actual transaction weight
Expected Behavior
The weight estimator should include all outputs, including the extra change output, to provide accurate size estimation.
Actual Behavior
The weight estimator only includes the main outputs but misses the extra change output, resulting in an underestimated transaction size.
Code Location
File: sweep/fee_bumper.go
Lines: 1704-1708
Something like this needs to be added on the LND side but also tested here on the LITD side. I cannot understand why we didn't run into this in our itests.
extraChangeOut.WhenSome(func(o SweepOutput) {
log.Infof("Adding extra change output %v to weight estimator",
o.Value)
estimator.addOutput(&o.TxOut)
})
However just adding this isn't enough because the witnesssize of the localTaprootCommitSpend seems to differ with overlay channels, compared a taproot channel with an overlay channel in terms of the witness size by 32 bytes => 8 vbytes!
See this example LocalAssetSweep:
"txid": "f10c2568e0761ae1237ad5f9cf97937634496e4951bcb7ef498c0dea854991b8",
"hash": "b493125886ac03a76bacc94162b0d8131970bfb2631e470b3125452cc9125795",
"version": 2,
"size": 234,
"vsize": 129,
"weight": 516,
"locktime": 513,
"vin": [
{
"txid": "6208f51938bc204cf158599a0764800a795b00029dca556a0e0be950779be0b8",
"vout": 2,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"e62913970013a8336106f210395c14faa3724f22898936b1ca3f74a9cf287291bd59ac2f0c138b6e3bc7f724b4bafcf02dfcb7447ed7166ea484ef8d120b7c6f",
"20d803c541003b94cfee17af01d9b9f757ec2e566f1d1213275a3f7ec549b7abebac51b275",
"c1dca094751109d0bd055d03565874e8276dd53e926b44e3bd1bb6bf4bc130a279"
],
"sequence": 1
}
],
"vout": [
{
"value": 0.00010870,
"n": 0,
"scriptPubKey": {
"asm": "1 4758048401a0ae19bea5a530602c8e56a62127c95694622beee0e2a3e734ca00",
"desc": "rawtr(4758048401a0ae19bea5a530602c8e56a62127c95694622beee0e2a3e734ca00)#6200sr9e",
"hex": "51204758048401a0ae19bea5a530602c8e56a62127c95694622beee0e2a3e734ca00",
"address": "bcrt1pgavqfpqp5zhpn04955cxqtyw26nzzf7f262xy2lwur328ee5egqqw8t3yx",
"type": "witness_v1_taproot"
}
}
],
"hex": "02000000000101b8e09b7750e90b0e6a55ca9d02005b790a8064079a5958f14c20bc3819f5086202000000000100000001762a0000000000002251204758048401a0ae19bea5a530602c8e56a62127c95694622beee0e2a3e734ca000340e62913970013a8336106f210395c14faa3724f22898936b1ca3f74a9cf287291bd59ac2f0c138b6e3bc7f724b4bafcf02dfcb7447ed7166ea484ef8d120b7c6f2520d803c541003b94cfee17af01d9b9f757ec2e566f1d1213275a3f7ec549b7abebac51b27521c1dca094751109d0bd055d03565874e8276dd53e926b44e3bd1bb6bf4bc130a27901020000"
}```