Update bdk_electrum crate to use sync/full-scan structs#1403
Update bdk_electrum crate to use sync/full-scan structs#1403notmandatory merged 13 commits intobitcoindevkit:masterfrom
bdk_electrum crate to use sync/full-scan structs#1403Conversation
53ed564 to
9033e0e
Compare
ValuedMammal
left a comment
There was a problem hiding this comment.
Looking good so far.
I made a note related to adding the client as a parameter to determine_tx_anchor - you may have already considered this. I see you mentioned potentially doing more batch calls, which is a good idea assuming we can ensure the results are in order consistent with the request.
side note: the commit message could use an extra newline after the subject and before the body.
6f39514 to
bb84d8f
Compare
d008d31 to
2540258
Compare
|
For the commit message, remember to put a new line between first line and body. |
|
It seems that you intended the sync flow to be:
However, the downsides of this approach is the following:
Hence, I think it is better to have a transaction cache |
077ea56 to
2905f09
Compare
2905f09 to
49c0c4e
Compare
f0278f5 to
a39a7e9
Compare
RelevantTxids and track txs in TxGraphbdk_electrum crate to use sync/full-scan structs
fdffdd0 to
93a4ae6
Compare
6628855 to
4ccd86a
Compare
This comment has been minimized.
This comment has been minimized.
This PR removes `RelevantTxids` from the electrum crate and tracks transactions in a `TxGraph`. This removes the need to separately construct a `TxGraph` after a `full_scan` or `sync`.
When we insert a transaction that is already wrapped in `Arc`, we should reuse the `Arc`.
This transaction cache can be provided so the chain-source can avoid re-fetching transactions.
|
This needs a rebase, merging #1203 broke this. |
`ElectrumResultExt` trait is also introduced that adds methods which can convert the `Anchor` type for the update `TxGraph`. We also make use of the new `TxCache` fields in `SyncRequest`/`FullScanRequest`. This way, we can avoid re-fetching full transactions from Electrum if not needed. Examples and tests are updated to use the new `ElectrumExt` API.
* Syncing with `example_electrum` now shows progress as a percentage. * Flush stdout more aggressively.
This is more code, but a much more elegant solution than having `ElectrumExt` methods return `SyncResult`/`FullScanResult` and having an `ElectrumResultExt` extention trait.
The previous `TxOut` for transactions received from an external wallet may be optionally added as floating `TxOut`s to `TxGraph` to allow for fee calculation.
323bfc7 to
92fb6cb
Compare
Helper method docs are updated to explain what they are updating. Logic is simplified as we do not need to check whether a tx exists already in `update_graph` before inserting it.
notmandatory
left a comment
There was a problem hiding this comment.
ACK b45897e
Tested with examples: example_electrum and wallet_electrum
Fixes #1265
Possibly fixes #1419
Context
Previous changes such as
CheckPointlinked list query-able (PR feat(chain): addgetandrangemethods toCheckPoint#1369)Transactions cheaply-clonable (PR Wrap transactions asArc<Transaction>inTxGraph#1373)has allowed us to simplify the interaction between chain-source and receiving-structures (
bdk_chain).The motivation is to accomplish something like this (as mentioned here):
Description
This PR greatly simplifies the API of our Electrum chain-source (
bdk_electrum) by making use of the aforementioned changes. Instead of referring back to the receivingTxGraphmid-sync/scan to determine which full transaction to fetch, we provide the Electrum chain-source already-fetched full transactions to start sync/scan (this is cheap, as transactions are wrapped inArcs since #1373).In addition, an option has been added to include the previous
TxOutfor transactions received from an external wallet for fee calculation.Changelog notice
TxGraph::insert_txto take in anything that satisfiesInto<Arc<Transaction>>. This allows us to reuse theArcpointer of what is being inserted.tx_cachefield toSyncRequestandFullScanRequest.Anchortype inFullScanResultgeneric for more flexibility.ElectrumExtmethods to take inSyncRequest/FullScanRequestand returnSyncResult/FullScanResult. Also update electrum examples accordingly.ElectrumResultExttrait which allows us to convert the updateTxGraphofSyncResult/FullScanResultforbdk_electrum.full_scanandsyncto also fetch previousTxOuts to allow for fee calculation.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features: