@@ -21,8 +21,8 @@ use alloc::{
2121} ;
2222pub use bdk_chain:: keychain:: Balance ;
2323use bdk_chain:: {
24- indexed_tx_graph:: IndexedAdditions ,
25- keychain:: { KeychainTxOutIndex , LocalChangeSet , LocalUpdate } ,
24+ indexed_tx_graph,
25+ keychain:: { KeychainTxOutIndex , WalletChangeSet , WalletUpdate } ,
2626 local_chain:: { self , CannotConnectError , CheckPoint , CheckPointIter , LocalChain } ,
2727 tx_graph:: { CanonicalTx , TxGraph } ,
2828 Append , BlockId , ChainPosition , ConfirmationTime , ConfirmationTimeAnchor , FullTxOut ,
@@ -95,10 +95,10 @@ pub struct Wallet<D = ()> {
9595}
9696
9797/// The update to a [`Wallet`] used in [`Wallet::apply_update`]. This is usually returned from blockchain data sources.
98- pub type Update = LocalUpdate < KeychainKind , ConfirmationTimeAnchor > ;
98+ pub type Update = WalletUpdate < KeychainKind , ConfirmationTimeAnchor > ;
9999
100100/// The changeset produced internally by [`Wallet`] when mutated.
101- pub type ChangeSet = LocalChangeSet < KeychainKind , ConfirmationTimeAnchor > ;
101+ pub type ChangeSet = WalletChangeSet < KeychainKind , ConfirmationTimeAnchor > ;
102102
103103/// The address index selection strategy to use to derived an address from the wallet's external
104104/// descriptor. See [`Wallet::get_address`]. If you're unsure which one to use use `WalletIndex::New`.
@@ -246,8 +246,8 @@ impl<D> Wallet<D> {
246246 } ;
247247
248248 let changeset = db. load_from_persistence ( ) . map_err ( NewError :: Persist ) ?;
249- chain. apply_changeset ( & changeset. chain_changeset ) ;
250- indexed_graph. apply_additions ( changeset. indexed_additions ) ;
249+ chain. apply_changeset ( & changeset. chain ) ;
250+ indexed_graph. apply_changeset ( changeset. index_tx_graph ) ;
251251
252252 let persist = Persist :: new ( db) ;
253253
@@ -320,14 +320,14 @@ impl<D> Wallet<D> {
320320 {
321321 let keychain = self . map_keychain ( keychain) ;
322322 let txout_index = & mut self . indexed_graph . index ;
323- let ( index, spk, additions ) = match address_index {
323+ let ( index, spk, changeset ) = match address_index {
324324 AddressIndex :: New => {
325- let ( ( index, spk) , index_additions ) = txout_index. reveal_next_spk ( & keychain) ;
326- ( index, spk. into ( ) , Some ( index_additions ) )
325+ let ( ( index, spk) , index_changeset ) = txout_index. reveal_next_spk ( & keychain) ;
326+ ( index, spk. into ( ) , Some ( index_changeset ) )
327327 }
328328 AddressIndex :: LastUnused => {
329- let ( ( index, spk) , index_additions ) = txout_index. next_unused_spk ( & keychain) ;
330- ( index, spk. into ( ) , Some ( index_additions ) )
329+ let ( ( index, spk) , index_changeset ) = txout_index. next_unused_spk ( & keychain) ;
330+ ( index, spk. into ( ) , Some ( index_changeset ) )
331331 }
332332 AddressIndex :: Peek ( index) => {
333333 let ( index, spk) = txout_index
@@ -339,9 +339,11 @@ impl<D> Wallet<D> {
339339 }
340340 } ;
341341
342- if let Some ( additions ) = additions {
342+ if let Some ( changeset ) = changeset {
343343 self . persist
344- . stage ( ChangeSet :: from ( IndexedAdditions :: from ( additions) ) ) ;
344+ . stage ( ChangeSet :: from ( indexed_tx_graph:: ChangeSet :: from (
345+ changeset,
346+ ) ) ) ;
345347 self . persist . commit ( ) ?;
346348 }
347349
@@ -436,12 +438,12 @@ impl<D> Wallet<D> {
436438 let graph = self . indexed_graph . graph ( ) ;
437439
438440 let canonical_tx = CanonicalTx {
439- observed_as : graph. get_chain_position (
441+ chain_position : graph. get_chain_position (
440442 & self . chain ,
441443 self . chain . tip ( ) . map ( |cp| cp. block_id ( ) ) . unwrap_or_default ( ) ,
442444 txid,
443445 ) ?,
444- node : graph. get_tx_node ( txid) ?,
446+ tx_node : graph. get_tx_node ( txid) ?,
445447 } ;
446448
447449 Some ( new_tx_details (
@@ -889,12 +891,14 @@ impl<D> Wallet<D> {
889891 Some ( ref drain_recipient) => drain_recipient. clone ( ) ,
890892 None => {
891893 let change_keychain = self . map_keychain ( KeychainKind :: Internal ) ;
892- let ( ( index, spk) , index_additions ) =
894+ let ( ( index, spk) , index_changeset ) =
893895 self . indexed_graph . index . next_unused_spk ( & change_keychain) ;
894896 let spk = spk. into ( ) ;
895897 self . indexed_graph . index . mark_used ( & change_keychain, index) ;
896898 self . persist
897- . stage ( ChangeSet :: from ( IndexedAdditions :: from ( index_additions) ) ) ;
899+ . stage ( ChangeSet :: from ( indexed_tx_graph:: ChangeSet :: from (
900+ index_changeset,
901+ ) ) ) ;
898902 self . persist . commit ( ) . expect ( "TODO" ) ;
899903 spk
900904 }
@@ -1286,7 +1290,7 @@ impl<D> Wallet<D> {
12861290 . indexed_graph
12871291 . graph ( )
12881292 . get_chain_position ( & self . chain , chain_tip, input. previous_output . txid )
1289- . map ( |observed_as | match observed_as {
1293+ . map ( |chain_position | match chain_position {
12901294 ChainPosition :: Confirmed ( a) => a. confirmation_height ,
12911295 ChainPosition :: Unconfirmed ( _) => u32:: MAX ,
12921296 } ) ;
@@ -1469,7 +1473,7 @@ impl<D> Wallet<D> {
14691473 . graph ( )
14701474 . get_chain_position ( & self . chain , chain_tip, txid)
14711475 {
1472- Some ( observed_as ) => observed_as . cloned ( ) . into ( ) ,
1476+ Some ( chain_position ) => chain_position . cloned ( ) . into ( ) ,
14731477 None => return false ,
14741478 } ;
14751479
@@ -1716,11 +1720,13 @@ impl<D> Wallet<D> {
17161720 D : PersistBackend < ChangeSet > ,
17171721 {
17181722 let mut changeset = ChangeSet :: from ( self . chain . apply_update ( update. chain ) ?) ;
1719- let ( _, index_additions ) = self
1723+ let ( _, index_changeset ) = self
17201724 . indexed_graph
17211725 . index
17221726 . reveal_to_target_multi ( & update. last_active_indices ) ;
1723- changeset. append ( ChangeSet :: from ( IndexedAdditions :: from ( index_additions) ) ) ;
1727+ changeset. append ( ChangeSet :: from ( indexed_tx_graph:: ChangeSet :: from (
1728+ index_changeset,
1729+ ) ) ) ;
17241730 changeset. append ( ChangeSet :: from (
17251731 self . indexed_graph . apply_update ( update. graph ) ,
17261732 ) ) ;
@@ -1827,7 +1833,7 @@ fn new_tx_details(
18271833) -> TransactionDetails {
18281834 let graph = indexed_graph. graph ( ) ;
18291835 let index = & indexed_graph. index ;
1830- let tx = canonical_tx. node . tx ;
1836+ let tx = canonical_tx. tx_node . tx ;
18311837
18321838 let received = tx
18331839 . output
@@ -1867,11 +1873,11 @@ fn new_tx_details(
18671873
18681874 TransactionDetails {
18691875 transaction : if include_raw { Some ( tx. clone ( ) ) } else { None } ,
1870- txid : canonical_tx. node . txid ,
1876+ txid : canonical_tx. tx_node . txid ,
18711877 received,
18721878 sent,
18731879 fee,
1874- confirmation_time : canonical_tx. observed_as . cloned ( ) . into ( ) ,
1880+ confirmation_time : canonical_tx. chain_position . cloned ( ) . into ( ) ,
18751881 }
18761882}
18771883
0 commit comments