@@ -17,7 +17,7 @@ use spaces_protocol::{
17
17
use spaces_wallet:: {
18
18
address:: SpaceAddress ,
19
19
bdk_wallet:: {
20
- chain:: { local_chain:: CheckPoint , BlockId } ,
20
+ chain:: { local_chain:: CheckPoint , BlockId , ChainPosition } ,
21
21
KeychainKind ,
22
22
} ,
23
23
bitcoin,
@@ -69,8 +69,9 @@ pub struct ListSpacesResponse {
69
69
#[ derive( Tabled , Debug , Clone , Serialize , Deserialize ) ]
70
70
#[ tabled( rename_all = "UPPERCASE" ) ]
71
71
pub struct TxInfo {
72
+ #[ tabled( display_with = "display_block_height" ) ]
73
+ pub block_height : Option < u32 > ,
72
74
pub txid : Txid ,
73
- pub confirmed : bool ,
74
75
pub sent : Amount ,
75
76
pub received : Amount ,
76
77
#[ tabled( display_with = "display_fee" ) ]
@@ -79,6 +80,13 @@ pub struct TxInfo {
79
80
pub events : Vec < TxEvent > ,
80
81
}
81
82
83
+ fn display_block_height ( block_height : & Option < u32 > ) -> String {
84
+ match block_height {
85
+ None => "Unconfirmed" . to_string ( ) ,
86
+ Some ( block_height) => block_height. to_string ( ) ,
87
+ }
88
+ }
89
+
82
90
fn display_fee ( fee : & Option < Amount > ) -> String {
83
91
match fee {
84
92
None => "--" . to_string ( ) ,
@@ -743,14 +751,17 @@ impl RpcWallet {
743
751
. skip ( skip)
744
752
. take ( count)
745
753
. map ( |ctx| {
754
+ let block_height = match ctx. chain_position {
755
+ ChainPosition :: Confirmed { anchor, .. } => Some ( anchor. block_id . height ) ,
756
+ ChainPosition :: Unconfirmed { .. } => None ,
757
+ } ;
746
758
let tx = ctx. tx_node . tx . clone ( ) ;
747
759
let txid = ctx. tx_node . txid . clone ( ) ;
748
- let confirmed = ctx. chain_position . is_confirmed ( ) ;
749
760
let ( sent, received) = wallet. sent_and_received ( & tx) ;
750
761
let fee = wallet. calculate_fee ( & tx) . ok ( ) ;
751
762
TxInfo {
763
+ block_height,
752
764
txid,
753
- confirmed,
754
765
sent,
755
766
received,
756
767
fee,
0 commit comments