Skip to content

Commit 2518ab9

Browse files
committed
more fields for TxInfo
1 parent 063a956 commit 2518ab9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

node/src/bin/space-cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ enum Commands {
210210
/// List last transactions
211211
#[command(name = "listtransactions")]
212212
ListTransactions {
213-
#[arg(default_value = "1")]
213+
#[arg(default_value = "10")]
214214
count: usize,
215215
#[arg(default_value = "0")]
216216
skip: usize,

node/src/wallets.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ pub struct TxResponse {
5454
pub struct TxInfo {
5555
pub txid: Txid,
5656
pub confirmed: bool,
57+
pub sent: Amount,
58+
pub received: Amount,
59+
pub fee: Option<Amount>,
5760
}
5861

5962
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -402,10 +405,19 @@ impl RpcWallet {
402405
.into_iter()
403406
.skip(skip)
404407
.take(count)
405-
.map(|tx| {
406-
let txid = tx.tx_node.txid.clone();
407-
let confirmed = tx.chain_position.is_confirmed();
408-
TxInfo { txid, confirmed }
408+
.map(|ctx| {
409+
let tx = ctx.tx_node.tx;
410+
let txid = ctx.tx_node.txid.clone();
411+
let confirmed = ctx.chain_position.is_confirmed();
412+
let (sent, received) = wallet.spaces.sent_and_received(&tx);
413+
let fee = wallet.spaces.calculate_fee(&tx).ok();
414+
TxInfo {
415+
txid,
416+
confirmed,
417+
sent,
418+
received,
419+
fee,
420+
}
409421
})
410422
.collect();
411423
Ok(transactions)

0 commit comments

Comments
 (0)