-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc externally-visible cleanups (nothing urgent) #3844
Misc externally-visible cleanups (nothing urgent) #3844
Conversation
+1 on bump reservations, but what should If you mean "move utxo from state 'reserved' to state 'spent'", I think neither If you mean "look at the outputs of this transaction and add those we own as utxos" I think neither We should really think more about the ramifications of supporting RBF. |
Currently, we tell the wallet about unconfirmed transactions. This is useful for spending unconfirmed outputs, and so users can
No, later patches change that to happen only when we see the tx in the blockchain, as you say.
Well, I have thought about it, and I agree! |
Which is why blanket-switching to "RBF EVERYTHING!!!!" is a bit dangerous IMO. Users have been used to C-lightning allowing spending from unconfirmed transactions generated by C-lightning itself (though we do not support spending from unconfirmed transactions created by anyone else: we do not maintain a mempool). No longer allowing spending from unconfirmed change is arguably a feature degradation, and implies that But even if we do not go "RBF EVERYTHING!!!!", if we have a PSBT that gets merged with a PSBT of somebody else, then the somebody else can double-spend the inputs and make the merged signed transaction invalid. Which means that, RBF or not. we cannot depend on change outputs existing until confirmed deeply. sigh. Perhaps what we can do would be to add yet another API,
Then, near the last step of This would let change outputs from ( PSBTs that are merged which spend coins owned by anyone else will be rejected by Basically, |
Affected User StoryYou have a C-Lightning node without any onchain funds, and some funds in some other wallet you control. Using this chunk of money, you create a new channel by
Now, you want to create yet another channel to a different node. A little while later, while miners are still not able to extend the chain and thus none of the transactions can be confirmed, you find out that you forgot to pay some onchain obligation. Then, a little while later, even while all those transactions are still unconfirmed, a friend requests a favor. At this point, you realize that the onchain funds being held by the C-Lightning node will no longer be usefully utilized, so you decide to put all remaining funds into cold storage. |
Old code: fundchannel tx is committed, we will never doublespend it.
Old code: will spend change.
Old code: will spend change.
Old code: will spend change.
Old code: will spend change. IOW, we should set the reservation should be long enough that this doesn't happen. But the ability to RBF is critical in modern bitcoin for fee efficiency. |
So, with this series sendpsbt kind of does this, but there are definitely future cases where you won't sendpsbt (dual funding in particular). There are two things here:
I'm tempted to say we should leave the plugin to do #1 itself (perhaps add an blocks arg to reserveinputs?), and provide a new "unconfirmedpsbt" call to do the second one? But we should also have code to detect that an unconfirmedpsbt is double-spent, and unreserve its inputs. We don't have that... |
Indeed, but we need to be very careful about how we expose RBF to users. I had some plans for RBF in the past, although only in the context of a new onchain-only wallet. Basically, the wallet maintains a set of "obligations", which are commands like "send x satoshi to y address", "cpfp incoming x satoshi from our address y", and periodically the wallet checks the blockchain and mempool for transacfions that it knows fulfill obligations. If it finds an obligation that is not fulfilled by any of the blockchain and mempool transactions, it looks for any mempool transaction it controls unilaterally, then mutates it to add unfulfilled obligations, and rebroadcasts it automatically with an RBFed transaction, then records that the transaction fulfills the obligations it added. If there is no such transaction, it creates a new one out of any coins it has control over. This is a fairly high-level system, however, and it is not clear to me if PSBT-usage would be compatible with such a system (such a system can be impemented on top of PSBTs, but I am uncertain if it can support PSBTs itself; need more time to think of what we can do if a transaction with an obligation can be RBFed, or how we handle things if we want to make a PSBT that is an RBF of an existing transaction). And if we allow obligations to be commands like "cpfp incoming funds", then we have to consider as well what we can do if there are multiple obligations, some of which are of the form "send funds" and others of the form "cpfp incoming funds" and then what happens if the sender of the funds to be cpfped RBFs the transaction from under us, and also what happens if we are sending out funds and the receiver cpfps it and now we want to RBF our own transaction and now we have to increase our fees enough to also evict the receiver CPFP transaction built on top. This means we need to start monitoring the mempool, which |
We need to make either a separate In particular, #3858 (comment) suggests to replace |
9d47b7b
to
82b9d81
Compare
82b9d81
to
dd211a9
Compare
Rebased on top of |
It's currently always 0, but it won't be once we replace txprepare. Signed-off-by: Rusty Russell <[email protected]> Changelog-Added: JSON-RPC: `fundchannel` has new `outnum` field indicating which output of the transaction funds the channel.
This is what txsend does, only we have a psbt so we have to change the db interface to take a wally_tx. Signed-off-by: Rusty Russell <[email protected]>
You'd need this if you ever wanted to make your own PSBT. Signed-off-by: Rusty Russell <[email protected]> Changelog-Added: `listfunds` now has a `redeemscript` field for p2sh-wrapped outputs.
dd211a9
to
2ed392a
Compare
@rustyrussell @ZmnSCPxj: Shall we move the discussion of how to properly add RBF support into a separate issue? To me it seems like the PR itself doesn't change much of the externally visible behavior and should be merged. ACK 2ed392a |
@cdecker seems ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2ed392a
(Based on #3843 see last 3 commits)
This adds some more info to our JSON outputs, and pushes transactions from sendpsbt into the wallet (otherwise they're not noticed, which confuses various tests once we port the other things onto it).
We could argue that signpsbt is where we should notify the wallet (and maybe, bump reservation on the inputs?), since they might not use sendpsbt through us, though we'll notice the tx when it's onchain. @niftynei @cdecker thoughts?