Repository navigation
splice: coin control for funds in (outpoints, lncli --utxo) - #8
Conversation
EstimateSplice and SpliceChannel take the wallet coins a splice in may spend: the amount comes only from them, or with use_max all of them go in. The coins left out count towards the reserve kept for fee-bumping anchor closes, so the chosen ones needn't keep it back. A coin the splice can't spend is refused with unknown_coin; outpoints with a splice out are an invalid argument.
|
Thanks, this is careful work: the reserve handling (coins left out still counting, and only coins the splice could actually spend counting) checks out, and so does RBF keeping the chosen inputs. The Fork checks failure is Two smaller things, optional:
|
…y what a splice can spend - rpcserver_splice_test.go: spliceRequest takes the outpoints too (go vet). - OnlyCoins refuses more outpoints than a splice takes (MaxInputsOrOutputs-1, 251): with --max, SelectAddFunds cut the candidates there and quietly left the rest out. - ErrUnknownCoin and the proto comments say that a splice spends only confirmed P2WKH and P2TR coins of the default account, never coinbase outputs: miners paying to their LND wallet would otherwise meet unknown_coin with no clue why.
|
Thanks Paul. Pushed 03ec9e3: the test call now passes the outpoints (vet clean), OnlyCoins refuses more than 251 outpoints instead of quietly spending the first 251, and ErrUnknownCoin plus the proto comments now say a splice only spends confirmed P2WKH/P2TR coins, never coinbase outputs. |
Coin control for adding funds with a splice.
EstimateSpliceandSpliceChanneltakeoutpoints(lncli splice in|estimate --utxo, repeatable): a splice in then spends only those wallet coins, the amount from them, or withuse_maxall of them. Without it nothing changes.The coins left out still count towards the reserve kept for fee-bumping anchor closes (
OnlyCoinslowers the reserve passed toSelectAddFundsby their value). Otherwise--maxover the chosen coins would always hold the whole reserve back as change from them, though the rest of the wallet already covers it.A coin the splice can't spend (not in the default account, unconfirmed, leased, spent) or one given twice is refused with the new refusal code
unknown_coin;outpointswith a splice out isInvalidArgument.Kilowallet wants this for its channel RESIZE, to match the coin control it has on every other on-chain spend.
Tests
TestOnlyCoins(lnwallet/splice): candidates narrowed, an amount taken from the chosen coin even when the wallet would pick a larger one first,--maxspending all the chosen coin with no change while the rest covers the reserve, the reserve reduced only by what the coins left out hold, unknown and duplicated coins refused.go test ./lnwallet/splice/passes.Regtest, two nodes built from this branch, Knots BLAKE2b regtest backend (
blake2b@150),protocol.splice=true:splice estimate in --amt 100000: fee 478 without--utxo, 499 with--utxo <200k>, so a different coin.--utxoof an unknown outpoint:refusal_code: unknown_coin.splice estimate out --utxo …:outpoints are for adding funds only.splice in --amt 100000 --utxo <200k>: the splice transaction's inputs are the funding output and that coin only; it locked, capacity 500,000.splice in --max --utxo <300k> --utxo <97,503 change>: both spent, no change output, the 599,671 coin untouched (it covers the 10,000 anchor reserve); locked, capacity 894,631.