@@ -98,88 +98,10 @@ where
9898 }
9999
100100 // create changeset
101- let descriptor: Descriptor < DescriptorPublicKey > = DESCRIPTORS [ 0 ] . parse ( ) . unwrap ( ) ;
102- let change_descriptor: Descriptor < DescriptorPublicKey > = DESCRIPTORS [ 1 ] . parse ( ) . unwrap ( ) ;
103-
104- let local_chain_changeset = local_chain:: ChangeSet {
105- blocks : [
106- ( 910234 , Some ( hash ! ( "B" ) ) ) ,
107- ( 910233 , Some ( hash ! ( "T" ) ) ) ,
108- ( 910235 , Some ( hash ! ( "C" ) ) ) ,
109- ]
110- . into ( ) ,
111- } ;
112-
113- let tx1 = Arc :: new ( create_one_inp_one_out_tx (
114- hash ! ( "We_are_all_Satoshi" ) ,
115- 30_000 ,
116- ) ) ;
117- let tx2 = Arc :: new ( create_one_inp_one_out_tx ( tx1. compute_txid ( ) , 20_000 ) ) ;
118-
119- let conf_anchor: ConfirmationBlockTime = ConfirmationBlockTime {
120- block_id : block_id ! ( 910234 , "B" ) ,
121- confirmation_time : 1755317160 ,
122- } ;
123-
124- let outpoint = OutPoint :: new ( hash ! ( "Rust" ) , 0 ) ;
125-
126- let tx_graph_changeset = tx_graph:: ChangeSet :: < ConfirmationBlockTime > {
127- txs : [ tx1. clone ( ) ] . into ( ) ,
128- txouts : [
129- (
130- outpoint,
131- TxOut {
132- value : Amount :: from_sat ( 1300 ) ,
133- script_pubkey : spk_at_index ( & descriptor, 4 ) ,
134- } ,
135- ) ,
136- (
137- OutPoint :: new ( hash ! ( "REDB" ) , 0 ) ,
138- TxOut {
139- value : Amount :: from_sat ( 1400 ) ,
140- script_pubkey : spk_at_index ( & descriptor, 10 ) ,
141- } ,
142- ) ,
143- ]
144- . into ( ) ,
145- anchors : [ ( conf_anchor, tx1. compute_txid ( ) ) ] . into ( ) ,
146- last_seen : [ ( tx1. compute_txid ( ) , 1755317760 ) ] . into ( ) ,
147- first_seen : [ ( tx1. compute_txid ( ) , 1755317750 ) ] . into ( ) ,
148- last_evicted : [ ( tx1. compute_txid ( ) , 1755317760 ) ] . into ( ) ,
149- } ;
150-
151- let keychain_txout_changeset = keychain_txout:: ChangeSet {
152- last_revealed : [
153- ( descriptor. descriptor_id ( ) , 12 ) ,
154- ( change_descriptor. descriptor_id ( ) , 10 ) ,
155- ]
156- . into ( ) ,
157- spk_cache : [
158- (
159- descriptor. descriptor_id ( ) ,
160- SpkIterator :: new_with_range ( & descriptor, 0 ..=37 ) . collect ( ) ,
161- ) ,
162- (
163- change_descriptor. descriptor_id ( ) ,
164- SpkIterator :: new_with_range ( & change_descriptor, 0 ..=35 ) . collect ( ) ,
165- ) ,
166- ]
167- . into ( ) ,
168- } ;
169-
170- let locked_outpoints_changeset = locked_outpoints:: ChangeSet {
171- outpoints : [ ( outpoint, true ) ] . into ( ) ,
172- } ;
101+ let tx1 = create_one_inp_one_out_tx ( hash ! ( "We_are_all_Satoshi" ) , 30_000 ) ;
102+ let tx2 = create_one_inp_one_out_tx ( tx1. compute_txid ( ) , 20_000 ) ;
173103
174- let mut changeset = ChangeSet {
175- descriptor : Some ( descriptor. clone ( ) ) ,
176- change_descriptor : Some ( change_descriptor. clone ( ) ) ,
177- network : Some ( Network :: Testnet ) ,
178- local_chain : local_chain_changeset,
179- tx_graph : tx_graph_changeset,
180- indexer : keychain_txout_changeset,
181- locked_outpoints : locked_outpoints_changeset,
182- } ;
104+ let mut changeset = get_changeset ( tx1) ;
183105
184106 // persist and load
185107 WalletPersister :: persist ( & mut store, & changeset) . map_err ( E :: persister) ?;
@@ -194,55 +116,7 @@ where
194116 }
195117
196118 // create another changeset
197- let local_chain_changeset = local_chain:: ChangeSet {
198- blocks : [ ( 910236 , Some ( hash ! ( "BDK" ) ) ) ] . into ( ) ,
199- } ;
200-
201- let conf_anchor: ConfirmationBlockTime = ConfirmationBlockTime {
202- block_id : block_id ! ( 910236 , "BDK" ) ,
203- confirmation_time : 1755317760 ,
204- } ;
205-
206- let outpoint = OutPoint :: new ( hash ! ( "Bitcoin_fixes_things" ) , 1 ) ;
207-
208- let tx_graph_changeset = tx_graph:: ChangeSet :: < ConfirmationBlockTime > {
209- txs : [ tx2. clone ( ) ] . into ( ) ,
210- txouts : [ (
211- outpoint,
212- TxOut {
213- value : Amount :: from_sat ( 10000 ) ,
214- script_pubkey : spk_at_index ( & descriptor, 21 ) ,
215- } ,
216- ) ]
217- . into ( ) ,
218- anchors : [ ( conf_anchor, tx2. compute_txid ( ) ) ] . into ( ) ,
219- last_seen : [ ( tx2. compute_txid ( ) , 1755317700 ) ] . into ( ) ,
220- first_seen : [ ( tx2. compute_txid ( ) , 1755317700 ) ] . into ( ) ,
221- last_evicted : [ ( tx2. compute_txid ( ) , 1755317760 ) ] . into ( ) ,
222- } ;
223-
224- let keychain_txout_changeset = keychain_txout:: ChangeSet {
225- last_revealed : [ ( descriptor. descriptor_id ( ) , 14 ) ] . into ( ) ,
226- spk_cache : [ (
227- descriptor. descriptor_id ( ) ,
228- SpkIterator :: new_with_range ( & descriptor, 37 ..=39 ) . collect ( ) ,
229- ) ]
230- . into ( ) ,
231- } ;
232-
233- let locked_outpoints_changeset = locked_outpoints:: ChangeSet {
234- outpoints : [ ( outpoint, true ) ] . into ( ) ,
235- } ;
236-
237- let changeset_new = ChangeSet {
238- descriptor : None ,
239- change_descriptor : None ,
240- network : None ,
241- local_chain : local_chain_changeset,
242- tx_graph : tx_graph_changeset,
243- indexer : keychain_txout_changeset,
244- locked_outpoints : locked_outpoints_changeset,
245- } ;
119+ let changeset_new = get_changeset_two ( tx2) ;
246120
247121 // persist, load and check if same as merged
248122 WalletPersister :: persist ( & mut store, & changeset_new) . map_err ( E :: persister) ?;
0 commit comments