mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-03 14:24:19 +01:00
Buy Bitcoin (#398)
* Add fiat on-ramp service * Use sdk-common MoonpayProvider * Bump flutter qr dependency * Bump sdk-common dependency
This commit is contained in:
@@ -54,6 +54,13 @@ pub(crate) enum Command {
|
||||
/// Amount the payer will send, in satoshi
|
||||
payer_amount_sat: u64,
|
||||
},
|
||||
/// Generates an URL to buy bitcoin from a 3rd party provider
|
||||
BuyBitcoin {
|
||||
provider: BuyBitcoinProvider,
|
||||
|
||||
/// Amount to buy, in satoshi
|
||||
amount_sat: u64,
|
||||
},
|
||||
/// List incoming and outgoing payments
|
||||
ListPayments {
|
||||
/// The optional from unix timestamp
|
||||
@@ -293,6 +300,37 @@ pub(crate) async fn handle_command(
|
||||
result.push_str(&build_qr_text(&bip21));
|
||||
result
|
||||
}
|
||||
Command::BuyBitcoin {
|
||||
provider,
|
||||
amount_sat,
|
||||
} => {
|
||||
let prepare_res = sdk
|
||||
.prepare_buy_bitcoin(&PrepareBuyBitcoinRequest {
|
||||
provider,
|
||||
amount_sat,
|
||||
})
|
||||
.await?;
|
||||
|
||||
wait_confirmation!(
|
||||
format!(
|
||||
"Fees: {} sat. Are the fees acceptable? (y/N) ",
|
||||
prepare_res.fees_sat
|
||||
),
|
||||
"Buy Bitcoin halted"
|
||||
);
|
||||
|
||||
let url = sdk
|
||||
.buy_bitcoin(&BuyBitcoinRequest {
|
||||
prepare_res,
|
||||
redirect_url: None,
|
||||
})
|
||||
.await?;
|
||||
|
||||
let mut result = command_result!(url.clone());
|
||||
result.push('\n');
|
||||
result.push_str(&build_qr_text(&url));
|
||||
result
|
||||
}
|
||||
Command::GetInfo => {
|
||||
command_result!(sdk.get_info().await?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user