mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-19 22:14:28 +01:00
Expose fees for review + auto accept
This commit is contained in:
@@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use breez_sdk_liquid::prelude::*;
|
||||
use clap::{arg, Parser};
|
||||
use qrcode_rs::render::unicode;
|
||||
@@ -131,6 +131,14 @@ pub(crate) enum Command {
|
||||
/// Lightning payment hash
|
||||
payment_hash: String,
|
||||
},
|
||||
/// Get proposed fees for WaitingFeeAcceptance Payment
|
||||
FetchPaymentProposedFees { swap_id: String },
|
||||
/// Accept proposed fees for WaitingFeeAcceptance Payment
|
||||
AcceptPaymentProposedFees {
|
||||
swap_id: String,
|
||||
// Fee amount obtained using FetchPaymentProposedFees
|
||||
fees_sat: u64,
|
||||
},
|
||||
/// List refundable chain swaps
|
||||
ListRefundables,
|
||||
/// Prepare a refund transaction for an incomplete swap
|
||||
@@ -519,6 +527,23 @@ pub(crate) async fn handle_command(
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::FetchPaymentProposedFees { swap_id } => {
|
||||
let res = sdk
|
||||
.fetch_payment_proposed_fees(&FetchPaymentProposedFeesRequest { swap_id })
|
||||
.await?;
|
||||
command_result!(res)
|
||||
}
|
||||
Command::AcceptPaymentProposedFees { swap_id, fees_sat } => {
|
||||
let res = sdk
|
||||
.fetch_payment_proposed_fees(&FetchPaymentProposedFeesRequest { swap_id })
|
||||
.await?;
|
||||
if fees_sat != res.fees_sat {
|
||||
bail!("Fees changed since they were fetched")
|
||||
}
|
||||
sdk.accept_payment_proposed_fees(&AcceptPaymentProposedFeesRequest { response: res })
|
||||
.await?;
|
||||
command_result!("Proposed fees accepted successfully")
|
||||
}
|
||||
Command::ListRefundables => {
|
||||
let refundables = sdk.list_refundables().await?;
|
||||
command_result!(refundables)
|
||||
|
||||
Reference in New Issue
Block a user