@@ -26,7 +26,6 @@ use bdk::{database::BatchDatabase, wallet::AddressIndex, Error, FeeRate, Keychai
2626
2727use clap:: Parser ;
2828
29-
3029use bdk:: bitcoin:: consensus:: encode:: { deserialize, serialize, serialize_hex} ;
3130#[ cfg( any(
3231 feature = "electrum" ,
@@ -88,9 +87,10 @@ use rustyline::error::ReadlineError;
8887use rustyline:: Editor ;
8988use serde_json:: json;
9089use std:: str:: FromStr ;
91- // Import some modules for payjoin functionality from payjoin crate
90+ // Import some modules for payjoin functionality
91+
9292
93- /// Execute an offline wallet sub-command
93+ // Execute an offline wallet sub-command
9494///
9595/// Offline wallet sub-commands are described in [`OfflineWalletSubCommand`].
9696pub fn handle_offline_wallet_subcommand < D > (
@@ -323,7 +323,11 @@ where
323323 B : Blockchain ,
324324 D : BatchDatabase ,
325325{
326- use bdk:: { signer:: InputSigner , wallet:: tx_builder, SyncOptions } ;
326+ use bdk:: SyncOptions ;
327+ use payjoin:: PjUriExt ;
328+ use payjoin:: UriExt ;
329+ use crate :: bitcoin:: psbt:: Input ;
330+ use std:: convert:: TryFrom ;
327331
328332 match online_subcommand {
329333 Sync => {
@@ -396,6 +400,7 @@ where
396400 Ok ( json ! ( { "spendable" : spendable } ) )
397401 }
398402
403+ #[ cfg( not( feature = "async-interface" ) ) ]
399404 // Payjoin Logic goes here
400405 SendPayjoin { uri } => {
401406 // convert the bip21 uri into a payjoin uri, and handle error if necessary
@@ -406,7 +411,7 @@ where
406411 // ensure uri is payjoin capable
407412 let uri = uri
408413 . check_pj_supported ( )
409- . map_err ( |e| Error :: Generic ( format ! ( "Payjoin not supported: {}" , e) ) ) ?;
414+ . map_err ( |e| Error :: Generic ( format ! ( "Payjoin not supported: {}" , e. to_string ( ) ) ) ) ?;
410415
411416 // ensure amount of satoshis is specified in uri, handle error if not
412417 let sats = match uri. amount {
@@ -483,7 +488,7 @@ where
483488 // get original inputs from original psbt clone (ocean_psbt)
484489 let mut original_inputs = input_pairs ( & mut ocean_psbt) . peekable ( ) ;
485490
486- for ( proposed_txin, mut proposed_psbtin) in input_pairs ( & mut payjoin_psbt) {
491+ for ( proposed_txin, proposed_psbtin) in input_pairs ( & mut payjoin_psbt) {
487492 if let Some ( ( original_txin, original_psbtin) ) = original_inputs. peek ( ) {
488493 if proposed_txin. previous_output == original_txin. previous_output {
489494 proposed_psbtin. witness_utxo = original_psbtin. witness_utxo . clone ( ) ;
0 commit comments