@@ -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 ( ) ,
@@ -720,14 +728,17 @@ impl RpcWallet {
720
728
. skip ( skip)
721
729
. take ( count)
722
730
. map ( |ctx| {
731
+ let block_height = match ctx. chain_position {
732
+ ChainPosition :: Confirmed { anchor, .. } => Some ( anchor. block_id . height ) ,
733
+ ChainPosition :: Unconfirmed { .. } => None ,
734
+ } ;
723
735
let tx = ctx. tx_node . tx . clone ( ) ;
724
736
let txid = ctx. tx_node . txid . clone ( ) ;
725
- let confirmed = ctx. chain_position . is_confirmed ( ) ;
726
737
let ( sent, received) = wallet. sent_and_received ( & tx) ;
727
738
let fee = wallet. calculate_fee ( & tx) . ok ( ) ;
728
739
TxInfo {
740
+ block_height,
729
741
txid,
730
- confirmed,
731
742
sent,
732
743
received,
733
744
fee,
0 commit comments