Repository navigation
fundchannel command: return an error when broadcast fails - #2274
Conversation
fundchannel command return an error when broadcast fails
|
I think this PR is enough for now. Maybe further improvements could be:
|
fundchannel command return an error when broadcast failsfundchannel command return an error when broadcast fails
fundchannel command return an error when broadcast fails
rustyrussell
left a comment
There was a problem hiding this comment.
OK, rebased this on top of a different fix, and changed the test. Still needs a couple of cosmetic changes...
|
Really like the way this is shaping up. It gives more control to the user. We might want to go a step further and move the following things into lightning/lightningd/opening_control.c Lines 408 to 409 in f96cdd9 lightning/lightningd/opening_control.c Line 425 in f96cdd9 The rationale behind this is that some users have reported a whole sequence of fundings failing, because each funding was using the change output of the previous one, which would not confirm. If we move those two parts into the success callback we avoid adding outputs that are unlikely to confirm, and we also delay marking the reserved outputs as spent (which is something that we might want to move to the output confirmation path anyway, instead of the funding path), making it easier to reset them should the funding fail indefinitely. Should the funding eventually confirm |
Let's make sure that this works if we die between telling bitcoind to add the tx to the mempool and getting the response. As far as I can tell, we'll then try to doublespend the output, which will fail: do we catch that case correctly if it's a wallet withdraw? IOW, I think that's a different change, which we should definitely do as a separate PR. |
|
Hmmm, hope I did this correctly ... rebased my local branch on 37c276d then --force pushed it back |
The UTXO is set to If we don't manually add the funding TX, and therefore the change output, we will grab it from the block once the funding confirms, so this really is just an optimization. I'm happy to move this to another PR, if we want to discuss it further, and unblock this PR 😉 |
Seems that you rebased on something that was not |
We actually produce an invalid JSON error at the moment: bitcoin-cli complains "JSON value is not an integer as expected" rather than returning the given error. Make our error a valid JSON RPC error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We could indeed make it further fail/fool-proof, but I don't see a way to do that without deeper modifications and new infrastructure.
Indeed something for a new PR. |
- result fundchannel command now depends on successful or failed broadcast of the funding tx - failure returns error code FUNDING_BROADCAST_FAIL - don't fail the channel when broadcast failed, but keep in CHANNELD_AWAITING_LOCKIN - after fixing the initial broadcast failure, the user could manually rebroadcast the tx and keep the channel openingd/opening_funder_finished: - broadcast_tx callback function now handles both success and failure jsonrpc: added error code FUNDING_BROADCAST_FAIL manpage: added error code returned by fundchannel command This makes the user more aware of broadcast failure, so it hopefully doesn't try to broadcast new tx's that depend on its change_outputs. Some users have reported (see issue #2171) a whole sequence of fundings failing, because each funding was using the change output of the previous one, which would not confirm.
This was proposed in ElementsProject#2274, as a way to avoid chaining multiple unconfirmed spends, by delaying the addition of change when we fail the broadcast. The main difference is when we extract our change output from a funding transaction and when we mark the reserved coins a spent. In case of failure, we'll still add the change script to the txfilter, but wait for confirmation before adding the change output itself. We'll also not mark the outputs as spent, but rather keep them reserved. Signed-off-by: Christian Decker <decker.christian@gmail.com>
openingd/json_fund_channel:
- result fundchannel command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- don't fail the channel when broadcast failed, but keep in CHANNELD_AWAITING_LOCKIN
- after fixing the initial broadcast failure, the user could manually rebroadcast the tx and
keep the channel
openingd/opening_funder_finished:
- broadcast_tx callback function now handles both success and failure
jsonrpc: added error code FUNDING_BROADCAST_FAIL
manpage: added error code returned by fundchannel command
This makes the user more aware of broadcast failure, so it hopefully doesn't
try to broadcast new tx's that depend on its change_outputs. Some users have reported (see
issue #2171) a whole sequence of fundings failing, because each funding was using the change
output of the previous one, which would not confirm.