Remove watch txids and make watches more bwatch-like: part 1#8927
Draft
rustyrussell wants to merge 24 commits intoElementsProject:masterfrom
Draft
Remove watch txids and make watches more bwatch-like: part 1#8927rustyrussell wants to merge 24 commits intoElementsProject:masterfrom
rustyrussell wants to merge 24 commits intoElementsProject:masterfrom
Conversation
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…while iterating. Not all of them, but I've done the ones which weren't obvious. Also, there's never a problem deleting during iteration, so remove places which tried to "handle" that problem. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
It's outpoint->txid in all cases. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We return this when we can: it's just a u64. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…he block We'll actually have it directly when we use outpoint watches from chaintopology, so we will be able to avoid the lookup. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
If it fails, we cannot proceed with the channel. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…e locked. This means splitting up the deptch_update_scid() a little. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…inflight_txwatch. We use typesafe callbacks: void * arguments are strongly eschewed. Indeed, when we fix this one, we find it's getting called wrong in splice_inflight_txwatch. Since we handed the wrong arg to splice_inflight_txwatch (channel instead of inflight), it never worked. Indeed, we always get: Splice inflight event but not in AWAITING_SPLICE, ending watch of txid f6f0cb65584389caf7722b06d9ffe98aea3ad8fd04d74b2b11e2e227cf28cffe So remove it. The watch will delete itself (as above), or be freed with the inflight. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
… output numbers. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
txfilter.c keeps a hash with interface: * INSERT: txfilter_add_scriptpubkey &txfilter_add_derkey * SEARCH: txfilter_match & txfilter_scriptpubkey_matches. It simply returns true/false. wallet.c keeps an our_addresses hash: * INSERT: on-demand when asked based on max keyidx (plus gap) * SEARCH: wallet_can_spend (and thus its caller wallet_extract_owned_outputs). Here are the places which populate the txfilter: lightningd/channel.c: - When we generate our own address final address => this is already covered when we call wallet_get_newindex() to get the final_key_idx lightningd/lightningd.c: - init_txfilter initializes all the prior addresses => wallet_can_spend populates this on first call. wallet/reservation.c: - finish_psbt and json_addpsbtoutput for change output => this is already covered when get call wallet_get_newindex() in the same funciton. wallet/wallet.c: - got_utxo for unconfirmed outputs => This is called when we have already determined we can spend the output (wallet_extract_owned_outputs), or on the fixup migration where the addresses are populated from a keyindex we've already created. wallet/walletrpc.c: - newaddr_inner => Already covered by wallet_get_newindex() The result: we can just rely on the wallet to find our addresses, and we don't need the txfilter at all. Just make chaintopology ask the wallet directly. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
chaintopology was the only user, so we don't need the txfilter at all. Remove it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Vital for hashing. But adding script_with_len_hash here breaks fuzzing build, so that requires a little modification. I also noticed that `#include <common/randbytes.h>` is redundant in all the common/ unit tests, so removed it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
The wallet has "our_addresses" which contains our own addresses; this adds a more generic callback mechanism which can be used for funding txs and splices. This will map better onto bwatch, which won't have ability to watch by txid. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…the funding tx. funding_depth_cb handled three cases, implicitly: 1. First time we see the funding tx. 2. When we see the funding tx block reorged out. 3. When we see the tx depth increase. This replaces first one with a scriptpubkey watch. The other two stay using the watch_txid for now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This handles the reorg case, ready to use a blockdepth callback next. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This is more explicit, and will work far better with an external watcher. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…lly closed. This is unnecessary now, since we have a destructor, but it'll be important when we move watching out to `bwatch`. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
It doesn't need to reinvent the wheel. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…ches for dual funding. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…ts mined. This also removed the last call to wallet_transaction_locate, so remove that too. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…n closing. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@sangbida is working on a generic watching plugin called bwatch; this is an internal cleanup and refactor to get us closer to being able to use her APIs.
This introduces internal scriptpubkey watches and blockdepth watches, which we then use to replace almost all the "txid" watches. I say almost all because onchaind needs to be reworked to avoid them too, but that will be a separate PR.
Still a draft: there have been some splicing and df breakages....