@@ -25,7 +25,7 @@ use bdk::wallet::tx_builder::ChangeSpendPolicy;
2525use bdk:: wallet:: AddressIndex as BdkAddressIndex ;
2626use bdk:: wallet:: AddressInfo as BdkAddressInfo ;
2727use bdk:: {
28- Balance as BdkBalance , BlockTime , Error , FeeRate , KeychainKind , SignOptions ,
28+ Balance as BdkBalance , BlockTime , Error as BdkError , FeeRate , KeychainKind , SignOptions ,
2929 SyncOptions as BdkSyncOptions , Wallet as BdkWallet ,
3030} ;
3131use std:: collections:: HashSet ;
@@ -178,7 +178,7 @@ struct Blockchain {
178178}
179179
180180impl Blockchain {
181- fn new ( blockchain_config : BlockchainConfig ) -> Result < Self , Error > {
181+ fn new ( blockchain_config : BlockchainConfig ) -> Result < Self , BdkError > {
182182 let any_blockchain_config = match blockchain_config {
183183 BlockchainConfig :: Electrum { config } => {
184184 AnyBlockchainConfig :: Electrum ( ElectrumBlockchainConfig {
@@ -209,16 +209,16 @@ impl Blockchain {
209209 self . blockchain_mutex . lock ( ) . expect ( "blockchain" )
210210 }
211211
212- fn broadcast ( & self , psbt : & PartiallySignedBitcoinTransaction ) -> Result < ( ) , Error > {
212+ fn broadcast ( & self , psbt : & PartiallySignedBitcoinTransaction ) -> Result < ( ) , BdkError > {
213213 let tx = psbt. internal . lock ( ) . unwrap ( ) . clone ( ) . extract_tx ( ) ;
214214 self . get_blockchain ( ) . broadcast ( & tx)
215215 }
216216
217- fn get_height ( & self ) -> Result < u32 , Error > {
217+ fn get_height ( & self ) -> Result < u32 , BdkError > {
218218 self . get_blockchain ( ) . get_height ( )
219219 }
220220
221- fn get_block_hash ( & self , height : u32 ) -> Result < String , Error > {
221+ fn get_block_hash ( & self , height : u32 ) -> Result < String , BdkError > {
222222 self . get_blockchain ( )
223223 . get_block_hash ( u64:: from ( height) )
224224 . map ( |hash| hash. to_string ( ) )
@@ -327,7 +327,7 @@ struct ProgressHolder {
327327}
328328
329329impl BdkProgress for ProgressHolder {
330- fn update ( & self , progress : f32 , message : Option < String > ) -> Result < ( ) , Error > {
330+ fn update ( & self , progress : f32 , message : Option < String > ) -> Result < ( ) , BdkError > {
331331 self . progress . update ( progress, message) ;
332332 Ok ( ( ) )
333333 }
@@ -345,7 +345,7 @@ pub struct PartiallySignedBitcoinTransaction {
345345}
346346
347347impl PartiallySignedBitcoinTransaction {
348- fn new ( psbt_base64 : String ) -> Result < Self , Error > {
348+ fn new ( psbt_base64 : String ) -> Result < Self , BdkError > {
349349 let psbt: PartiallySignedTransaction = PartiallySignedTransaction :: from_str ( & psbt_base64) ?;
350350 Ok ( PartiallySignedBitcoinTransaction {
351351 internal : Mutex :: new ( psbt) ,
@@ -379,7 +379,7 @@ impl PartiallySignedBitcoinTransaction {
379379 fn combine (
380380 & self ,
381381 other : Arc < PartiallySignedBitcoinTransaction > ,
382- ) -> Result < Arc < PartiallySignedBitcoinTransaction > , Error > {
382+ ) -> Result < Arc < PartiallySignedBitcoinTransaction > , BdkError > {
383383 let other_psbt = other. internal . lock ( ) . unwrap ( ) . clone ( ) ;
384384 let mut original_psbt = self . internal . lock ( ) . unwrap ( ) . clone ( ) ;
385385
@@ -401,7 +401,7 @@ impl Wallet {
401401 change_descriptor : Option < String > ,
402402 network : Network ,
403403 database_config : DatabaseConfig ,
404- ) -> Result < Self , Error > {
404+ ) -> Result < Self , BdkError > {
405405 let any_database_config = match database_config {
406406 DatabaseConfig :: Memory => AnyDatabaseConfig :: Memory ( ( ) ) ,
407407 DatabaseConfig :: Sled { config } => AnyDatabaseConfig :: Sled ( config) ,
@@ -431,7 +431,7 @@ impl Wallet {
431431 & self ,
432432 blockchain : & Blockchain ,
433433 progress : Option < Box < dyn Progress > > ,
434- ) -> Result < ( ) , Error > {
434+ ) -> Result < ( ) , BdkError > {
435435 let bdk_sync_opts = BdkSyncOptions {
436436 progress : progress. map ( |p| {
437437 Box :: new ( ProgressHolder { progress : p } )
@@ -446,26 +446,26 @@ impl Wallet {
446446 /// Return a derived address using the external descriptor, see AddressIndex for available address index selection
447447 /// strategies. If none of the keys in the descriptor are derivable (i.e. the descriptor does not end with a * character)
448448 /// then the same address will always be returned for any AddressIndex.
449- fn get_address ( & self , address_index : AddressIndex ) -> Result < AddressInfo , Error > {
449+ fn get_address ( & self , address_index : AddressIndex ) -> Result < AddressInfo , BdkError > {
450450 self . get_wallet ( )
451451 . get_address ( address_index. into ( ) )
452452 . map ( AddressInfo :: from)
453453 }
454454
455455 /// Return the balance, meaning the sum of this wallet’s unspent outputs’ values. Note that this method only operates
456456 /// on the internal database, which first needs to be Wallet.sync manually.
457- fn get_balance ( & self ) -> Result < Balance , Error > {
457+ fn get_balance ( & self ) -> Result < Balance , BdkError > {
458458 self . get_wallet ( ) . get_balance ( ) . map ( |b| b. into ( ) )
459459 }
460460
461461 /// Sign a transaction with all the wallet’s signers.
462- fn sign ( & self , psbt : & PartiallySignedBitcoinTransaction ) -> Result < bool , Error > {
462+ fn sign ( & self , psbt : & PartiallySignedBitcoinTransaction ) -> Result < bool , BdkError > {
463463 let mut psbt = psbt. internal . lock ( ) . unwrap ( ) ;
464464 self . get_wallet ( ) . sign ( & mut psbt, SignOptions :: default ( ) )
465465 }
466466
467467 /// Return the list of transactions made and received by the wallet. Note that this method only operate on the internal database, which first needs to be [Wallet.sync] manually.
468- fn list_transactions ( & self ) -> Result < Vec < TransactionDetails > , Error > {
468+ fn list_transactions ( & self ) -> Result < Vec < TransactionDetails > , BdkError > {
469469 let transaction_details = self . get_wallet ( ) . list_transactions ( true ) ?;
470470 Ok ( transaction_details
471471 . iter ( )
@@ -475,7 +475,7 @@ impl Wallet {
475475
476476 /// Return the list of unspent outputs of this wallet. Note that this method only operates on the internal database,
477477 /// which first needs to be Wallet.sync manually.
478- fn list_unspent ( & self ) -> Result < Vec < LocalUtxo > , Error > {
478+ fn list_unspent ( & self ) -> Result < Vec < LocalUtxo > , BdkError > {
479479 let unspents = self . get_wallet ( ) . list_unspent ( ) ?;
480480 Ok ( unspents
481481 . iter ( )
@@ -484,10 +484,10 @@ impl Wallet {
484484 }
485485}
486486
487- fn to_script_pubkey ( address : & str ) -> Result < BdkScript , Error > {
487+ fn to_script_pubkey ( address : & str ) -> Result < BdkScript , BdkError > {
488488 BdkAddress :: from_str ( address)
489489 . map ( |x| x. script_pubkey ( ) )
490- . map_err ( |e| Error :: Generic ( e. to_string ( ) ) )
490+ . map_err ( |e| BdkError :: Generic ( e. to_string ( ) ) )
491491}
492492
493493/// A Bitcoin address.
@@ -496,10 +496,10 @@ struct Address {
496496}
497497
498498impl Address {
499- fn new ( address : String ) -> Result < Self , Error > {
499+ fn new ( address : String ) -> Result < Self , BdkError > {
500500 BdkAddress :: from_str ( address. as_str ( ) )
501501 . map ( |a| Address { address : a } )
502- . map_err ( |e| Error :: Generic ( e. to_string ( ) ) )
502+ . map_err ( |e| BdkError :: Generic ( e. to_string ( ) ) )
503503 }
504504
505505 fn script_pubkey ( & self ) -> Arc < Script > {
@@ -720,7 +720,7 @@ impl TxBuilder {
720720 }
721721
722722 /// Finish building the transaction. Returns the BIP174 PSBT.
723- fn finish ( & self , wallet : & Wallet ) -> Result < TxBuilderResult , Error > {
723+ fn finish ( & self , wallet : & Wallet ) -> Result < TxBuilderResult , BdkError > {
724724 let wallet = wallet. get_wallet ( ) ;
725725 let mut tx_builder = wallet. build_tx ( ) ;
726726 for ( script, amount) in & self . recipients {
@@ -827,14 +827,14 @@ impl BumpFeeTxBuilder {
827827 }
828828
829829 /// Finish building the transaction. Returns the BIP174 PSBT.
830- fn finish ( & self , wallet : & Wallet ) -> Result < Arc < PartiallySignedBitcoinTransaction > , Error > {
830+ fn finish ( & self , wallet : & Wallet ) -> Result < Arc < PartiallySignedBitcoinTransaction > , BdkError > {
831831 let wallet = wallet. get_wallet ( ) ;
832832 let txid = Txid :: from_str ( self . txid . as_str ( ) ) ?;
833833 let mut tx_builder = wallet. build_fee_bump ( txid) ?;
834834 tx_builder. fee_rate ( FeeRate :: from_sat_per_vb ( self . fee_rate ) ) ;
835835 if let Some ( allow_shrinking) = & self . allow_shrinking {
836- let address =
837- BdkAddress :: from_str ( allow_shrinking ) . map_err ( |e| Error :: Generic ( e. to_string ( ) ) ) ?;
836+ let address = BdkAddress :: from_str ( allow_shrinking )
837+ . map_err ( |e| BdkError :: Generic ( e. to_string ( ) ) ) ?;
838838 let script = address. script_pubkey ( ) ;
839839 tx_builder. allow_shrinking ( script) ?;
840840 }
@@ -857,7 +857,7 @@ impl BumpFeeTxBuilder {
857857 }
858858}
859859
860- fn generate_mnemonic ( word_count : WordCount ) -> Result < String , Error > {
860+ fn generate_mnemonic ( word_count : WordCount ) -> Result < String , BdkError > {
861861 let mnemonic: GeneratedKey < _ , BareCtx > =
862862 Mnemonic :: generate ( ( word_count, Language :: English ) ) . unwrap ( ) ;
863863 Ok ( mnemonic. to_string ( ) )
@@ -868,12 +868,12 @@ struct DerivationPath {
868868}
869869
870870impl DerivationPath {
871- fn new ( path : String ) -> Result < Self , Error > {
871+ fn new ( path : String ) -> Result < Self , BdkError > {
872872 BdkDerivationPath :: from_str ( & path)
873873 . map ( |x| DerivationPath {
874874 derivation_path_mutex : Mutex :: new ( x) ,
875875 } )
876- . map_err ( |e| Error :: Generic ( e. to_string ( ) ) )
876+ . map_err ( |e| BdkError :: Generic ( e. to_string ( ) ) )
877877 }
878878}
879879
@@ -882,9 +882,9 @@ struct DescriptorSecretKey {
882882}
883883
884884impl DescriptorSecretKey {
885- fn new ( network : Network , mnemonic : String , password : Option < String > ) -> Result < Self , Error > {
885+ fn new ( network : Network , mnemonic : String , password : Option < String > ) -> Result < Self , BdkError > {
886886 let mnemonic = Mnemonic :: parse_in ( Language :: English , mnemonic)
887- . map_err ( |e| Error :: Generic ( e. to_string ( ) ) ) ?;
887+ . map_err ( |e| BdkError :: Generic ( e. to_string ( ) ) ) ?;
888888 let xkey: ExtendedKey = ( mnemonic, password) . into_extended_key ( ) ?;
889889 let descriptor_secret_key = BdkDescriptorSecretKey :: XPrv ( DescriptorXKey {
890890 origin : None ,
@@ -897,7 +897,7 @@ impl DescriptorSecretKey {
897897 } )
898898 }
899899
900- fn derive ( & self , path : Arc < DerivationPath > ) -> Result < Arc < Self > , Error > {
900+ fn derive ( & self , path : Arc < DerivationPath > ) -> Result < Arc < Self > , BdkError > {
901901 let secp = Secp256k1 :: new ( ) ;
902902 let descriptor_secret_key = self . descriptor_secret_key_mutex . lock ( ) . unwrap ( ) ;
903903 let path = path. derivation_path_mutex . lock ( ) . unwrap ( ) . deref ( ) . clone ( ) ;
@@ -984,7 +984,7 @@ struct DescriptorPublicKey {
984984}
985985
986986impl DescriptorPublicKey {
987- fn derive ( & self , path : Arc < DerivationPath > ) -> Result < Arc < Self > , Error > {
987+ fn derive ( & self , path : Arc < DerivationPath > ) -> Result < Arc < Self > , BdkError > {
988988 let secp = Secp256k1 :: new ( ) ;
989989 let descriptor_public_key = self . descriptor_public_key_mutex . lock ( ) . unwrap ( ) ;
990990 let path = path. derivation_path_mutex . lock ( ) . unwrap ( ) . deref ( ) . clone ( ) ;
@@ -1126,7 +1126,7 @@ mod test {
11261126 fn derive_dsk (
11271127 key : & DescriptorSecretKey ,
11281128 path : & str ,
1129- ) -> Result < Arc < DescriptorSecretKey > , Error > {
1129+ ) -> Result < Arc < DescriptorSecretKey > , BdkError > {
11301130 let path = Arc :: new ( DerivationPath :: new ( path. to_string ( ) ) . unwrap ( ) ) ;
11311131 key. derive ( path)
11321132 }
@@ -1139,7 +1139,7 @@ mod test {
11391139 fn derive_dpk (
11401140 key : & DescriptorPublicKey ,
11411141 path : & str ,
1142- ) -> Result < Arc < DescriptorPublicKey > , Error > {
1142+ ) -> Result < Arc < DescriptorPublicKey > , BdkError > {
11431143 let path = Arc :: new ( DerivationPath :: new ( path. to_string ( ) ) . unwrap ( ) ) ;
11441144 key. derive ( path)
11451145 }
0 commit comments