11use crate :: commands:: OfflineWalletSubCommand ;
22use crate :: error:: BDKCliError as Error ;
33use crate :: handlers:: { AppCommand , AppContext } ;
4- use crate :: utils:: output:: FormatOutput ;
4+ use crate :: utils:: output:: { FormatOutput , ListResult } ;
55use crate :: utils:: parse_address;
66use crate :: utils:: types:: {
77 AddressResult , BalanceResult , KeychainPair , PsbtResult , RawPsbt , TransactionDetails ,
8- TransactionListResult , UnspentDetails , UnspentListResult ,
8+ UnspentDetails ,
99} ;
1010use crate :: utils:: { parse_outpoint, parse_recipient} ;
1111use bdk_wallet:: bitcoin:: base64:: Engine ;
@@ -27,31 +27,47 @@ use {
2727impl OfflineWalletSubCommand {
2828 pub fn execute ( & self , ctx : & mut AppContext < ' _ > ) -> Result < ( ) , Error > {
2929 match self {
30- Self :: NewAddress ( new_address) => new_address. execute ( ctx) ?. print ( ) ,
31- Self :: Balance ( balance) => balance. execute ( ctx) ?. print ( ) ,
32- Self :: UnusedAddress ( unused_address_command) => {
33- unused_address_command. execute ( ctx) ?. print ( )
30+ Self :: NewAddress ( new_address) => new_address. execute ( ctx) ?. write_out ( std:: io:: stdout ( ) ) ,
31+ Self :: Balance ( balance) => balance. execute ( ctx) ?. write_out ( std:: io:: stdout ( ) ) ,
32+ Self :: UnusedAddress ( unused_address_command) => unused_address_command
33+ . execute ( ctx) ?
34+ . write_out ( std:: io:: stdout ( ) ) ,
35+ Self :: Unspent ( unspent_command) => {
36+ unspent_command. execute ( ctx) ?. write_out ( std:: io:: stdout ( ) )
3437 }
35- Self :: Unspent ( unspent_command) => unspent_command. execute ( ctx) ?. print ( ) ,
36- Self :: Transactions ( transactions_command) => transactions_command. execute ( ctx) ?. print ( ) ,
37- Self :: CreateTx ( createtx_command) => createtx_command. execute ( ctx) ?. print ( ) ,
38- Self :: BumpFee ( bumpfee_command) => bumpfee_command. execute ( ctx) ?. print ( ) ,
39- Self :: Policies ( policies_command) => policies_command. execute ( ctx) ?. print ( ) ,
40- Self :: PublicDescriptor ( public_descriptor_command) => {
41- public_descriptor_command. execute ( ctx) ?. print ( )
38+ Self :: Transactions ( transactions_command) => transactions_command
39+ . execute ( ctx) ?
40+ . write_out ( std:: io:: stdout ( ) ) ,
41+ Self :: CreateTx ( createtx_command) => {
42+ createtx_command. execute ( ctx) ?. write_out ( std:: io:: stdout ( ) )
4243 }
43- Self :: Sign ( sign_command) => sign_command. execute ( ctx) ?. print ( ) ,
44- Self :: ExtractPsbt ( extract_psbt_command) => extract_psbt_command. execute ( ctx) ?. print ( ) ,
45- Self :: FinalizePsbt ( finalize_psbt_command) => {
46- finalize_psbt_command. execute ( ctx) ?. print ( )
44+ Self :: BumpFee ( bumpfee_command) => {
45+ bumpfee_command. execute ( ctx) ?. write_out ( std:: io:: stdout ( ) )
4746 }
48- Self :: CombinePsbt ( combine_psbt_command) => combine_psbt_command. execute ( ctx) ?. print ( ) ,
47+ Self :: Policies ( policies_command) => {
48+ policies_command. execute ( ctx) ?. write_out ( std:: io:: stdout ( ) )
49+ }
50+ Self :: PublicDescriptor ( public_descriptor_command) => public_descriptor_command
51+ . execute ( ctx) ?
52+ . write_out ( std:: io:: stdout ( ) ) ,
53+ Self :: Sign ( sign_command) => sign_command. execute ( ctx) ?. write_out ( std:: io:: stdout ( ) ) ,
54+ Self :: ExtractPsbt ( extract_psbt_command) => extract_psbt_command
55+ . execute ( ctx) ?
56+ . write_out ( std:: io:: stdout ( ) ) ,
57+ Self :: FinalizePsbt ( finalize_psbt_command) => finalize_psbt_command
58+ . execute ( ctx) ?
59+ . write_out ( std:: io:: stdout ( ) ) ,
60+ Self :: CombinePsbt ( combine_psbt_command) => combine_psbt_command
61+ . execute ( ctx) ?
62+ . write_out ( std:: io:: stdout ( ) ) ,
4963 #[ cfg( feature = "bip322" ) ]
50- Self :: SignMessage ( sign_message_command) => sign_message_command. execute ( ctx) ?. print ( ) ,
64+ Self :: SignMessage ( sign_message_command) => sign_message_command
65+ . execute ( ctx) ?
66+ . write_out ( std:: io:: stdout ( ) ) ,
5167 #[ cfg( feature = "bip322" ) ]
52- Self :: VerifyMessage ( verify_message_command) => {
53- verify_message_command . execute ( ctx) ?. print ( )
54- }
68+ Self :: VerifyMessage ( verify_message_command) => verify_message_command
69+ . execute ( ctx) ?
70+ . write_out ( std :: io :: stdout ( ) ) ,
5571 }
5672 }
5773}
@@ -92,7 +108,7 @@ impl AppCommand for UnusedAddressCommand {
92108pub struct UnspentCommand { }
93109
94110impl AppCommand for UnspentCommand {
95- type Output = UnspentListResult ;
111+ type Output = ListResult < UnspentDetails > ;
96112
97113 fn execute ( & self , ctx : & mut AppContext ) -> Result < Self :: Output , Error > {
98114 let wallet = ctx
@@ -104,15 +120,15 @@ impl AppCommand for UnspentCommand {
104120 . map ( |utxo| UnspentDetails :: from_local_output ( & utxo, ctx. network ) )
105121 . collect ( ) ;
106122
107- Ok ( UnspentListResult ( utxos) )
123+ Ok ( ListResult :: new ( utxos) )
108124 }
109125}
110126
111127#[ derive( Parser , Debug , PartialEq , Clone ) ]
112128pub struct TransactionsCommand { }
113129
114130impl AppCommand for TransactionsCommand {
115- type Output = TransactionListResult ;
131+ type Output = ListResult < TransactionDetails > ;
116132
117133 fn execute ( & self , ctx : & mut AppContext ) -> Result < Self :: Output , Error > {
118134 let wallet = ctx
@@ -147,7 +163,7 @@ impl AppCommand for TransactionsCommand {
147163 } )
148164 . collect ( ) ;
149165
150- Ok ( TransactionListResult ( txns) )
166+ Ok ( ListResult :: new ( txns) )
151167 }
152168}
153169
0 commit comments