feat: add invoice_amount_sat field to swaps (#33)

* fix: rebasing and updating cargo.lock

* feat: add `requested-amount-sat` field to pending swaps

* lint

* feat: added list-payments method

* linting

* feat: adding pending transactions to list-payments

* fix: rename received_amount to invoice_amount

* fix: renaming Pending to PendingReceive

* fix: remove expect from preimage unwrapping
This commit is contained in:
yse
2024-03-21 15:05:08 +01:00
committed by GitHub
parent d254496269
commit 03c2c3918a
7 changed files with 115 additions and 82 deletions

View File

@@ -16,6 +16,8 @@ pub(crate) enum Command {
SendPayment { bolt11: String },
/// Receive lbtc and send btc through a swap
ReceivePayment { amount_sat: u64 },
/// List incoming and outgoing payments
ListPayments,
/// Get the balance of the currently loaded wallet
GetInfo,
}
@@ -56,7 +58,7 @@ pub(crate) async fn handle_command(
response.txid
))
}
Command::GetInfo {} => {
Command::GetInfo => {
let info = wallet.get_info(true)?;
Ok(format!(
@@ -64,5 +66,26 @@ pub(crate) async fn handle_command(
info.balance_sat, info.pubkey, info.active_address
))
}
Command::ListPayments => {
let payments_str = wallet
.list_payments(true, true)?
.iter()
.map(|tx| {
format!(
"Id: {} | Type: {} | Amount: {} sat | Timestamp: {}",
tx.id.clone().unwrap_or("None".to_string()),
tx.payment_type.to_string(),
tx.amount_sat,
match tx.timestamp {
Some(t) => t.to_string(),
None => "None".to_string(),
},
)
})
.collect::<Vec<String>>()
.join("\n");
Ok(payments_str)
}
}
}