@@ -10,7 +10,9 @@ use bdk_chain::{
1010 tx_graph:: Additions ,
1111 BlockId , ChainPosition , ConfirmationHeightAnchor ,
1212} ;
13- use bitcoin:: { secp256k1:: Secp256k1 , BlockHash , OutPoint , Script , Transaction , TxIn , TxOut } ;
13+ use bitcoin:: {
14+ secp256k1:: Secp256k1 , BlockHash , OutPoint , Script , ScriptBuf , Transaction , TxIn , TxOut ,
15+ } ;
1416use miniscript:: Descriptor ;
1517
1618/// Ensure [`IndexedTxGraph::insert_relevant_txs`] can successfully index transactions NOT presented
@@ -25,8 +27,8 @@ fn insert_relevant_txs() {
2527 const DESCRIPTOR : & str = "tr([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/0/*)" ;
2628 let ( descriptor, _) = Descriptor :: parse_descriptor ( & Secp256k1 :: signing_only ( ) , DESCRIPTOR )
2729 . expect ( "must be valid" ) ;
28- let spk_0 = descriptor. at_derivation_index ( 0 ) . script_pubkey ( ) ;
29- let spk_1 = descriptor. at_derivation_index ( 9 ) . script_pubkey ( ) ;
30+ let spk_0 = descriptor. at_derivation_index ( 0 ) . unwrap ( ) . script_pubkey ( ) ;
31+ let spk_1 = descriptor. at_derivation_index ( 9 ) . unwrap ( ) . script_pubkey ( ) ;
3032
3133 let mut graph = IndexedTxGraph :: < ConfirmationHeightAnchor , KeychainTxOutIndex < ( ) > > :: default ( ) ;
3234 graph. index . add_keychain ( ( ) , descriptor) ;
@@ -127,21 +129,21 @@ fn test_list_owned_txouts() {
127129
128130 // Get trusted and untrusted addresses
129131
130- let mut trusted_spks = Vec :: new ( ) ;
131- let mut untrusted_spks = Vec :: new ( ) ;
132+ let mut trusted_spks: Vec < ScriptBuf > = Vec :: new ( ) ;
133+ let mut untrusted_spks: Vec < ScriptBuf > = Vec :: new ( ) ;
132134
133135 {
134136 // we need to scope here to take immutanble reference of the graph
135137 for _ in 0 ..10 {
136138 let ( ( _, script) , _) = graph. index . reveal_next_spk ( & "keychain_1" . to_string ( ) ) ;
137139 // TODO Assert indexes
138- trusted_spks. push ( script. clone ( ) ) ;
140+ trusted_spks. push ( script. to_owned ( ) ) ;
139141 }
140142 }
141143 {
142144 for _ in 0 ..10 {
143145 let ( ( _, script) , _) = graph. index . reveal_next_spk ( & "keychain_2" . to_string ( ) ) ;
144- untrusted_spks. push ( script. clone ( ) ) ;
146+ untrusted_spks. push ( script. to_owned ( ) ) ;
145147 }
146148 }
147149
@@ -155,7 +157,7 @@ fn test_list_owned_txouts() {
155157 } ] ,
156158 output : vec ! [ TxOut {
157159 value: 70000 ,
158- script_pubkey: trusted_spks[ 0 ] . clone ( ) ,
160+ script_pubkey: trusted_spks[ 0 ] . to_owned ( ) ,
159161 } ] ,
160162 ..common:: new_tx ( 0 )
161163 } ;
@@ -164,7 +166,7 @@ fn test_list_owned_txouts() {
164166 let tx2 = Transaction {
165167 output : vec ! [ TxOut {
166168 value: 30000 ,
167- script_pubkey: untrusted_spks[ 0 ] . clone ( ) ,
169+ script_pubkey: untrusted_spks[ 0 ] . to_owned ( ) ,
168170 } ] ,
169171 ..common:: new_tx ( 0 )
170172 } ;
@@ -177,7 +179,7 @@ fn test_list_owned_txouts() {
177179 } ] ,
178180 output : vec ! [ TxOut {
179181 value: 10000 ,
180- script_pubkey: trusted_spks[ 1 ] . clone ( ) ,
182+ script_pubkey: trusted_spks[ 1 ] . to_owned ( ) ,
181183 } ] ,
182184 ..common:: new_tx ( 0 )
183185 } ;
@@ -186,7 +188,7 @@ fn test_list_owned_txouts() {
186188 let tx4 = Transaction {
187189 output : vec ! [ TxOut {
188190 value: 20000 ,
189- script_pubkey: untrusted_spks[ 1 ] . clone ( ) ,
191+ script_pubkey: untrusted_spks[ 1 ] . to_owned ( ) ,
190192 } ] ,
191193 ..common:: new_tx ( 0 )
192194 } ;
@@ -195,7 +197,7 @@ fn test_list_owned_txouts() {
195197 let tx5 = Transaction {
196198 output : vec ! [ TxOut {
197199 value: 15000 ,
198- script_pubkey: trusted_spks[ 2 ] . clone ( ) ,
200+ script_pubkey: trusted_spks[ 2 ] . to_owned ( ) ,
199201 } ] ,
200202 ..common:: new_tx ( 0 )
201203 } ;
@@ -258,7 +260,7 @@ fn test_list_owned_txouts() {
258260 & local_chain,
259261 chain_tip,
260262 graph. index . outpoints ( ) . iter ( ) . cloned ( ) ,
261- |_, spk : & Script | trusted_spks. contains ( spk) ,
263+ |_, spk : & Script | trusted_spks. contains ( & spk. to_owned ( ) ) ,
262264 ) ;
263265
264266 assert_eq ! ( txouts. len( ) , 5 ) ;
0 commit comments