mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-19 15:04:24 +01:00
Update boltz-rust and add receive payment description (#409)
* Update boltz-rust * Store description and add to Payment struct * Fix examples
This commit is contained in:
2
cli/Cargo.lock
generated
2
cli/Cargo.lock
generated
@@ -494,7 +494,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "boltz-client"
|
name = "boltz-client"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
source = "git+https://github.com/hydra-yse/boltz-rust?branch=yse-breez-latest#d308ce0e7b84030373191e1621dda1f9fbed623c"
|
source = "git+https://github.com/SatoshiPortal/boltz-rust?rev=d6092c746e998696ebe1128444141bdcd66fc172#d6092c746e998696ebe1128444141bdcd66fc172"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bip39",
|
"bip39",
|
||||||
"bitcoin 0.31.2",
|
"bitcoin 0.31.2",
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ pub(crate) enum Command {
|
|||||||
ReceivePayment {
|
ReceivePayment {
|
||||||
/// Amount the payer will send, in satoshi
|
/// Amount the payer will send, in satoshi
|
||||||
payer_amount_sat: u64,
|
payer_amount_sat: u64,
|
||||||
|
|
||||||
|
/// Optional description for the invoice
|
||||||
|
#[clap(short = 'd', long = "description")]
|
||||||
|
description: Option<String>,
|
||||||
},
|
},
|
||||||
/// Receive lbtc and send btc onchain through a swap
|
/// Receive lbtc and send btc onchain through a swap
|
||||||
ReceiveOnchainPayment {
|
ReceiveOnchainPayment {
|
||||||
@@ -195,20 +199,28 @@ pub(crate) async fn handle_command(
|
|||||||
command: Command,
|
command: Command,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
Ok(match command {
|
Ok(match command {
|
||||||
Command::ReceivePayment { payer_amount_sat } => {
|
Command::ReceivePayment {
|
||||||
let prepare_response = sdk
|
payer_amount_sat,
|
||||||
.prepare_receive_payment(&PrepareReceiveRequest { payer_amount_sat })
|
description,
|
||||||
|
} => {
|
||||||
|
let prepare_res = sdk
|
||||||
|
.prepare_receive_payment(&PrepareReceivePaymentRequest { payer_amount_sat })
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
wait_confirmation!(
|
wait_confirmation!(
|
||||||
format!(
|
format!(
|
||||||
"Fees: {} sat. Are the fees acceptable? (y/N) ",
|
"Fees: {} sat. Are the fees acceptable? (y/N) ",
|
||||||
prepare_response.fees_sat
|
prepare_res.fees_sat
|
||||||
),
|
),
|
||||||
"Payment receive halted"
|
"Payment receive halted"
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = sdk.receive_payment(&prepare_response).await?;
|
let response = sdk
|
||||||
|
.receive_payment(&ReceivePaymentRequest {
|
||||||
|
prepare_res,
|
||||||
|
description,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
let invoice = response.invoice.clone();
|
let invoice = response.invoice.clone();
|
||||||
|
|
||||||
let mut result = command_result!(response);
|
let mut result = command_result!(response);
|
||||||
|
|||||||
2
lib/Cargo.lock
generated
2
lib/Cargo.lock
generated
@@ -614,7 +614,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "boltz-client"
|
name = "boltz-client"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
source = "git+https://github.com/hydra-yse/boltz-rust?branch=yse-breez-latest#d308ce0e7b84030373191e1621dda1f9fbed623c"
|
source = "git+https://github.com/SatoshiPortal/boltz-rust?rev=d6092c746e998696ebe1128444141bdcd66fc172#d6092c746e998696ebe1128444141bdcd66fc172"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bip39",
|
"bip39",
|
||||||
"bitcoin 0.31.2",
|
"bitcoin 0.31.2",
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ typedef struct wire_cst_prepare_receive_onchain_request {
|
|||||||
uint64_t payer_amount_sat;
|
uint64_t payer_amount_sat;
|
||||||
} wire_cst_prepare_receive_onchain_request;
|
} wire_cst_prepare_receive_onchain_request;
|
||||||
|
|
||||||
typedef struct wire_cst_prepare_receive_request {
|
typedef struct wire_cst_prepare_receive_payment_request {
|
||||||
uint64_t payer_amount_sat;
|
uint64_t payer_amount_sat;
|
||||||
} wire_cst_prepare_receive_request;
|
} wire_cst_prepare_receive_payment_request;
|
||||||
|
|
||||||
typedef struct wire_cst_prepare_refund_request {
|
typedef struct wire_cst_prepare_refund_request {
|
||||||
struct wire_cst_list_prim_u_8_strict *swap_address;
|
struct wire_cst_list_prim_u_8_strict *swap_address;
|
||||||
@@ -155,10 +155,15 @@ typedef struct wire_cst_prepare_receive_onchain_response {
|
|||||||
uint64_t fees_sat;
|
uint64_t fees_sat;
|
||||||
} wire_cst_prepare_receive_onchain_response;
|
} wire_cst_prepare_receive_onchain_response;
|
||||||
|
|
||||||
typedef struct wire_cst_prepare_receive_response {
|
typedef struct wire_cst_prepare_receive_payment_response {
|
||||||
uint64_t payer_amount_sat;
|
uint64_t payer_amount_sat;
|
||||||
uint64_t fees_sat;
|
uint64_t fees_sat;
|
||||||
} wire_cst_prepare_receive_response;
|
} wire_cst_prepare_receive_payment_response;
|
||||||
|
|
||||||
|
typedef struct wire_cst_receive_payment_request {
|
||||||
|
struct wire_cst_list_prim_u_8_strict *description;
|
||||||
|
struct wire_cst_prepare_receive_payment_response prepare_res;
|
||||||
|
} wire_cst_receive_payment_request;
|
||||||
|
|
||||||
typedef struct wire_cst_refund_request {
|
typedef struct wire_cst_refund_request {
|
||||||
struct wire_cst_list_prim_u_8_strict *swap_address;
|
struct wire_cst_list_prim_u_8_strict *swap_address;
|
||||||
@@ -187,6 +192,7 @@ typedef struct wire_cst_payment {
|
|||||||
uint64_t fees_sat;
|
uint64_t fees_sat;
|
||||||
struct wire_cst_list_prim_u_8_strict *preimage;
|
struct wire_cst_list_prim_u_8_strict *preimage;
|
||||||
struct wire_cst_list_prim_u_8_strict *bolt11;
|
struct wire_cst_list_prim_u_8_strict *bolt11;
|
||||||
|
struct wire_cst_list_prim_u_8_strict *description;
|
||||||
struct wire_cst_list_prim_u_8_strict *refund_tx_id;
|
struct wire_cst_list_prim_u_8_strict *refund_tx_id;
|
||||||
uint64_t *refund_tx_amount_sat;
|
uint64_t *refund_tx_amount_sat;
|
||||||
int32_t payment_type;
|
int32_t payment_type;
|
||||||
@@ -863,7 +869,7 @@ void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive
|
|||||||
|
|
||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(int64_t port_,
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(int64_t port_,
|
||||||
uintptr_t that,
|
uintptr_t that,
|
||||||
struct wire_cst_prepare_receive_request *req);
|
struct wire_cst_prepare_receive_payment_request *req);
|
||||||
|
|
||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_refund(int64_t port_,
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_refund(int64_t port_,
|
||||||
uintptr_t that,
|
uintptr_t that,
|
||||||
@@ -879,7 +885,7 @@ void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_onchain
|
|||||||
|
|
||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(int64_t port_,
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(int64_t port_,
|
||||||
uintptr_t that,
|
uintptr_t that,
|
||||||
struct wire_cst_prepare_receive_response *req);
|
struct wire_cst_receive_payment_request *req);
|
||||||
|
|
||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_recommended_fees(int64_t port_,
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_recommended_fees(int64_t port_,
|
||||||
uintptr_t that);
|
uintptr_t that);
|
||||||
@@ -976,9 +982,7 @@ struct wire_cst_prepare_receive_onchain_request *frbgen_breez_liquid_cst_new_box
|
|||||||
|
|
||||||
struct wire_cst_prepare_receive_onchain_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_response(void);
|
struct wire_cst_prepare_receive_onchain_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_response(void);
|
||||||
|
|
||||||
struct wire_cst_prepare_receive_request *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request(void);
|
struct wire_cst_prepare_receive_payment_request *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request(void);
|
||||||
|
|
||||||
struct wire_cst_prepare_receive_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response(void);
|
|
||||||
|
|
||||||
struct wire_cst_prepare_refund_request *frbgen_breez_liquid_cst_new_box_autoadd_prepare_refund_request(void);
|
struct wire_cst_prepare_refund_request *frbgen_breez_liquid_cst_new_box_autoadd_prepare_refund_request(void);
|
||||||
|
|
||||||
@@ -986,6 +990,8 @@ struct wire_cst_prepare_send_request *frbgen_breez_liquid_cst_new_box_autoadd_pr
|
|||||||
|
|
||||||
struct wire_cst_prepare_send_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response(void);
|
struct wire_cst_prepare_send_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response(void);
|
||||||
|
|
||||||
|
struct wire_cst_receive_payment_request *frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request(void);
|
||||||
|
|
||||||
struct wire_cst_refund_request *frbgen_breez_liquid_cst_new_box_autoadd_refund_request(void);
|
struct wire_cst_refund_request *frbgen_breez_liquid_cst_new_box_autoadd_refund_request(void);
|
||||||
|
|
||||||
struct wire_cst_restore_request *frbgen_breez_liquid_cst_new_box_autoadd_restore_request(void);
|
struct wire_cst_restore_request *frbgen_breez_liquid_cst_new_box_autoadd_restore_request(void);
|
||||||
@@ -1050,11 +1056,11 @@ static int64_t dummy_method_to_enforce_bundling(void) {
|
|||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_pay_onchain_request);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_pay_onchain_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_request);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_response);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_response);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response);
|
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_refund_request);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_refund_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_request);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response);
|
||||||
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_refund_request);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_refund_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_restore_request);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_restore_request);
|
||||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_sdk_event);
|
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_sdk_event);
|
||||||
|
|||||||
@@ -93,18 +93,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: graphs
|
name: graphs
|
||||||
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
|
sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.1"
|
version: "2.3.2"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
|
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.2"
|
||||||
http_parser:
|
http_parser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -309,10 +309,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: web
|
name: web
|
||||||
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.1"
|
version: "1.0.0"
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -325,15 +325,20 @@ dictionary SendPaymentResponse {
|
|||||||
Payment payment;
|
Payment payment;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary PrepareReceiveRequest {
|
dictionary PrepareReceivePaymentRequest {
|
||||||
u64 payer_amount_sat;
|
u64 payer_amount_sat;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary PrepareReceiveResponse {
|
dictionary PrepareReceivePaymentResponse {
|
||||||
u64 payer_amount_sat;
|
u64 payer_amount_sat;
|
||||||
u64 fees_sat;
|
u64 fees_sat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary ReceivePaymentRequest {
|
||||||
|
PrepareReceivePaymentResponse prepare_res;
|
||||||
|
string? description = null;
|
||||||
|
};
|
||||||
|
|
||||||
dictionary ReceivePaymentResponse {
|
dictionary ReceivePaymentResponse {
|
||||||
string id;
|
string id;
|
||||||
string invoice;
|
string invoice;
|
||||||
@@ -427,6 +432,7 @@ dictionary Payment {
|
|||||||
u64 fees_sat;
|
u64 fees_sat;
|
||||||
PaymentType payment_type;
|
PaymentType payment_type;
|
||||||
PaymentState status;
|
PaymentState status;
|
||||||
|
string description;
|
||||||
string? tx_id = null;
|
string? tx_id = null;
|
||||||
string? swap_id = null;
|
string? swap_id = null;
|
||||||
string? preimage = null;
|
string? preimage = null;
|
||||||
@@ -543,10 +549,10 @@ interface BindingLiquidSdk {
|
|||||||
SendPaymentResponse send_payment(PrepareSendResponse req);
|
SendPaymentResponse send_payment(PrepareSendResponse req);
|
||||||
|
|
||||||
[Throws=PaymentError]
|
[Throws=PaymentError]
|
||||||
PrepareReceiveResponse prepare_receive_payment(PrepareReceiveRequest req);
|
PrepareReceivePaymentResponse prepare_receive_payment(PrepareReceivePaymentRequest req);
|
||||||
|
|
||||||
[Throws=PaymentError]
|
[Throws=PaymentError]
|
||||||
ReceivePaymentResponse receive_payment(PrepareReceiveResponse req);
|
ReceivePaymentResponse receive_payment(ReceivePaymentRequest req);
|
||||||
|
|
||||||
[Throws=PaymentError]
|
[Throws=PaymentError]
|
||||||
LightningPaymentLimitsResponse fetch_lightning_limits();
|
LightningPaymentLimitsResponse fetch_lightning_limits();
|
||||||
|
|||||||
@@ -110,14 +110,14 @@ impl BindingLiquidSdk {
|
|||||||
|
|
||||||
pub fn prepare_receive_payment(
|
pub fn prepare_receive_payment(
|
||||||
&self,
|
&self,
|
||||||
req: PrepareReceiveRequest,
|
req: PrepareReceivePaymentRequest,
|
||||||
) -> Result<PrepareReceiveResponse, PaymentError> {
|
) -> Result<PrepareReceivePaymentResponse, PaymentError> {
|
||||||
rt().block_on(self.sdk.prepare_receive_payment(&req))
|
rt().block_on(self.sdk.prepare_receive_payment(&req))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn receive_payment(
|
pub fn receive_payment(
|
||||||
&self,
|
&self,
|
||||||
req: PrepareReceiveResponse,
|
req: ReceivePaymentRequest,
|
||||||
) -> Result<ReceivePaymentResponse, PaymentError> {
|
) -> Result<ReceivePaymentResponse, PaymentError> {
|
||||||
rt().block_on(self.sdk.receive_payment(&req))
|
rt().block_on(self.sdk.receive_payment(&req))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ frb = ["dep:flutter_rust_bridge"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
bip39 = "2.0.0"
|
bip39 = "2.0.0"
|
||||||
#boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", rev = "a05731cc33030ada9ae14afcafe0cded22842ba6" }
|
boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", rev = "d6092c746e998696ebe1128444141bdcd66fc172" }
|
||||||
boltz-client = { git = "https://github.com/hydra-yse/boltz-rust", branch = "yse-breez-latest" }
|
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
flutter_rust_bridge = { version = "=2.0.0", features = ["chrono"], optional = true }
|
flutter_rust_bridge = { version = "=2.0.0", features = ["chrono"], optional = true }
|
||||||
|
|||||||
@@ -114,14 +114,14 @@ impl BindingLiquidSdk {
|
|||||||
|
|
||||||
pub async fn prepare_receive_payment(
|
pub async fn prepare_receive_payment(
|
||||||
&self,
|
&self,
|
||||||
req: PrepareReceiveRequest,
|
req: PrepareReceivePaymentRequest,
|
||||||
) -> Result<PrepareReceiveResponse, PaymentError> {
|
) -> Result<PrepareReceivePaymentResponse, PaymentError> {
|
||||||
self.sdk.prepare_receive_payment(&req).await
|
self.sdk.prepare_receive_payment(&req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn receive_payment(
|
pub async fn receive_payment(
|
||||||
&self,
|
&self,
|
||||||
req: PrepareReceiveResponse,
|
req: ReceivePaymentRequest,
|
||||||
) -> Result<ReceivePaymentResponse, PaymentError> {
|
) -> Result<ReceivePaymentResponse, PaymentError> {
|
||||||
self.sdk.receive_payment(&req).await
|
self.sdk.receive_payment(&req).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use std::time::Duration;
|
|||||||
use std::{str::FromStr, sync::Arc};
|
use std::{str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use boltz_client::swaps::boltzv2::{self, SwapUpdateTxDetails};
|
use boltz_client::swaps::boltz::{self, SwapUpdateTxDetails};
|
||||||
use boltz_client::swaps::{boltz::ChainSwapStates, boltzv2::CreateChainResponse};
|
use boltz_client::swaps::{boltz::ChainSwapStates, boltz::CreateChainResponse};
|
||||||
use boltz_client::Secp256k1;
|
use boltz_client::Secp256k1;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use lwk_wollet::elements::Transaction;
|
use lwk_wollet::elements::Transaction;
|
||||||
@@ -84,7 +84,7 @@ impl ChainSwapStateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handles status updates from Boltz for Chain swaps
|
/// Handles status updates from Boltz for Chain swaps
|
||||||
pub(crate) async fn on_new_status(&self, update: &boltzv2::Update) -> Result<()> {
|
pub(crate) async fn on_new_status(&self, update: &boltz::Update) -> Result<()> {
|
||||||
let id = &update.id;
|
let id = &update.id;
|
||||||
let swap = self
|
let swap = self
|
||||||
.persister
|
.persister
|
||||||
@@ -177,11 +177,7 @@ impl ChainSwapStateHandler {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn on_new_incoming_status(
|
async fn on_new_incoming_status(&self, swap: &ChainSwap, update: &boltz::Update) -> Result<()> {
|
||||||
&self,
|
|
||||||
swap: &ChainSwap,
|
|
||||||
update: &boltzv2::Update,
|
|
||||||
) -> Result<()> {
|
|
||||||
let id = &update.id;
|
let id = &update.id;
|
||||||
let status = &update.status;
|
let status = &update.status;
|
||||||
let swap_state = ChainSwapStates::from_str(status)
|
let swap_state = ChainSwapStates::from_str(status)
|
||||||
@@ -320,11 +316,7 @@ impl ChainSwapStateHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn on_new_outgoing_status(
|
async fn on_new_outgoing_status(&self, swap: &ChainSwap, update: &boltz::Update) -> Result<()> {
|
||||||
&self,
|
|
||||||
swap: &ChainSwap,
|
|
||||||
update: &boltzv2::Update,
|
|
||||||
) -> Result<()> {
|
|
||||||
let id = &update.id;
|
let id = &update.id;
|
||||||
let status = &update.status;
|
let status = &update.status;
|
||||||
let swap_state = ChainSwapStates::from_str(status)
|
let swap_state = ChainSwapStates::from_str(status)
|
||||||
|
|||||||
@@ -344,18 +344,13 @@ impl CstDecode<crate::model::PrepareReceiveOnchainResponse>
|
|||||||
CstDecode::<crate::model::PrepareReceiveOnchainResponse>::cst_decode(*wrap).into()
|
CstDecode::<crate::model::PrepareReceiveOnchainResponse>::cst_decode(*wrap).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl CstDecode<crate::model::PrepareReceiveRequest> for *mut wire_cst_prepare_receive_request {
|
impl CstDecode<crate::model::PrepareReceivePaymentRequest>
|
||||||
|
for *mut wire_cst_prepare_receive_payment_request
|
||||||
|
{
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
fn cst_decode(self) -> crate::model::PrepareReceiveRequest {
|
fn cst_decode(self) -> crate::model::PrepareReceivePaymentRequest {
|
||||||
let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) };
|
let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) };
|
||||||
CstDecode::<crate::model::PrepareReceiveRequest>::cst_decode(*wrap).into()
|
CstDecode::<crate::model::PrepareReceivePaymentRequest>::cst_decode(*wrap).into()
|
||||||
}
|
|
||||||
}
|
|
||||||
impl CstDecode<crate::model::PrepareReceiveResponse> for *mut wire_cst_prepare_receive_response {
|
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
|
||||||
fn cst_decode(self) -> crate::model::PrepareReceiveResponse {
|
|
||||||
let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) };
|
|
||||||
CstDecode::<crate::model::PrepareReceiveResponse>::cst_decode(*wrap).into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl CstDecode<crate::model::PrepareRefundRequest> for *mut wire_cst_prepare_refund_request {
|
impl CstDecode<crate::model::PrepareRefundRequest> for *mut wire_cst_prepare_refund_request {
|
||||||
@@ -379,6 +374,13 @@ impl CstDecode<crate::model::PrepareSendResponse> for *mut wire_cst_prepare_send
|
|||||||
CstDecode::<crate::model::PrepareSendResponse>::cst_decode(*wrap).into()
|
CstDecode::<crate::model::PrepareSendResponse>::cst_decode(*wrap).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl CstDecode<crate::model::ReceivePaymentRequest> for *mut wire_cst_receive_payment_request {
|
||||||
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
|
fn cst_decode(self) -> crate::model::ReceivePaymentRequest {
|
||||||
|
let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) };
|
||||||
|
CstDecode::<crate::model::ReceivePaymentRequest>::cst_decode(*wrap).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
impl CstDecode<crate::model::RefundRequest> for *mut wire_cst_refund_request {
|
impl CstDecode<crate::model::RefundRequest> for *mut wire_cst_refund_request {
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
fn cst_decode(self) -> crate::model::RefundRequest {
|
fn cst_decode(self) -> crate::model::RefundRequest {
|
||||||
@@ -1089,6 +1091,7 @@ impl CstDecode<crate::model::Payment> for wire_cst_payment {
|
|||||||
fees_sat: self.fees_sat.cst_decode(),
|
fees_sat: self.fees_sat.cst_decode(),
|
||||||
preimage: self.preimage.cst_decode(),
|
preimage: self.preimage.cst_decode(),
|
||||||
bolt11: self.bolt11.cst_decode(),
|
bolt11: self.bolt11.cst_decode(),
|
||||||
|
description: self.description.cst_decode(),
|
||||||
refund_tx_id: self.refund_tx_id.cst_decode(),
|
refund_tx_id: self.refund_tx_id.cst_decode(),
|
||||||
refund_tx_amount_sat: self.refund_tx_amount_sat.cst_decode(),
|
refund_tx_amount_sat: self.refund_tx_amount_sat.cst_decode(),
|
||||||
payment_type: self.payment_type.cst_decode(),
|
payment_type: self.payment_type.cst_decode(),
|
||||||
@@ -1217,18 +1220,22 @@ impl CstDecode<crate::model::PrepareReceiveOnchainResponse>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl CstDecode<crate::model::PrepareReceiveRequest> for wire_cst_prepare_receive_request {
|
impl CstDecode<crate::model::PrepareReceivePaymentRequest>
|
||||||
|
for wire_cst_prepare_receive_payment_request
|
||||||
|
{
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
fn cst_decode(self) -> crate::model::PrepareReceiveRequest {
|
fn cst_decode(self) -> crate::model::PrepareReceivePaymentRequest {
|
||||||
crate::model::PrepareReceiveRequest {
|
crate::model::PrepareReceivePaymentRequest {
|
||||||
payer_amount_sat: self.payer_amount_sat.cst_decode(),
|
payer_amount_sat: self.payer_amount_sat.cst_decode(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl CstDecode<crate::model::PrepareReceiveResponse> for wire_cst_prepare_receive_response {
|
impl CstDecode<crate::model::PrepareReceivePaymentResponse>
|
||||||
|
for wire_cst_prepare_receive_payment_response
|
||||||
|
{
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
fn cst_decode(self) -> crate::model::PrepareReceiveResponse {
|
fn cst_decode(self) -> crate::model::PrepareReceivePaymentResponse {
|
||||||
crate::model::PrepareReceiveResponse {
|
crate::model::PrepareReceivePaymentResponse {
|
||||||
payer_amount_sat: self.payer_amount_sat.cst_decode(),
|
payer_amount_sat: self.payer_amount_sat.cst_decode(),
|
||||||
fees_sat: self.fees_sat.cst_decode(),
|
fees_sat: self.fees_sat.cst_decode(),
|
||||||
}
|
}
|
||||||
@@ -1289,6 +1296,15 @@ impl CstDecode<crate::model::ReceiveOnchainResponse> for wire_cst_receive_onchai
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl CstDecode<crate::model::ReceivePaymentRequest> for wire_cst_receive_payment_request {
|
||||||
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
|
fn cst_decode(self) -> crate::model::ReceivePaymentRequest {
|
||||||
|
crate::model::ReceivePaymentRequest {
|
||||||
|
description: self.description.cst_decode(),
|
||||||
|
prepare_res: self.prepare_res.cst_decode(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
impl CstDecode<crate::model::ReceivePaymentResponse> for wire_cst_receive_payment_response {
|
impl CstDecode<crate::model::ReceivePaymentResponse> for wire_cst_receive_payment_response {
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
fn cst_decode(self) -> crate::model::ReceivePaymentResponse {
|
fn cst_decode(self) -> crate::model::ReceivePaymentResponse {
|
||||||
@@ -2023,6 +2039,7 @@ impl NewWithNullPtr for wire_cst_payment {
|
|||||||
fees_sat: Default::default(),
|
fees_sat: Default::default(),
|
||||||
preimage: core::ptr::null_mut(),
|
preimage: core::ptr::null_mut(),
|
||||||
bolt11: core::ptr::null_mut(),
|
bolt11: core::ptr::null_mut(),
|
||||||
|
description: core::ptr::null_mut(),
|
||||||
refund_tx_id: core::ptr::null_mut(),
|
refund_tx_id: core::ptr::null_mut(),
|
||||||
refund_tx_amount_sat: core::ptr::null_mut(),
|
refund_tx_amount_sat: core::ptr::null_mut(),
|
||||||
payment_type: Default::default(),
|
payment_type: Default::default(),
|
||||||
@@ -2127,19 +2144,19 @@ impl Default for wire_cst_prepare_receive_onchain_response {
|
|||||||
Self::new_with_null_ptr()
|
Self::new_with_null_ptr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl NewWithNullPtr for wire_cst_prepare_receive_request {
|
impl NewWithNullPtr for wire_cst_prepare_receive_payment_request {
|
||||||
fn new_with_null_ptr() -> Self {
|
fn new_with_null_ptr() -> Self {
|
||||||
Self {
|
Self {
|
||||||
payer_amount_sat: Default::default(),
|
payer_amount_sat: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Default for wire_cst_prepare_receive_request {
|
impl Default for wire_cst_prepare_receive_payment_request {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new_with_null_ptr()
|
Self::new_with_null_ptr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl NewWithNullPtr for wire_cst_prepare_receive_response {
|
impl NewWithNullPtr for wire_cst_prepare_receive_payment_response {
|
||||||
fn new_with_null_ptr() -> Self {
|
fn new_with_null_ptr() -> Self {
|
||||||
Self {
|
Self {
|
||||||
payer_amount_sat: Default::default(),
|
payer_amount_sat: Default::default(),
|
||||||
@@ -2147,7 +2164,7 @@ impl NewWithNullPtr for wire_cst_prepare_receive_response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Default for wire_cst_prepare_receive_response {
|
impl Default for wire_cst_prepare_receive_payment_response {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new_with_null_ptr()
|
Self::new_with_null_ptr()
|
||||||
}
|
}
|
||||||
@@ -2231,6 +2248,19 @@ impl Default for wire_cst_receive_onchain_response {
|
|||||||
Self::new_with_null_ptr()
|
Self::new_with_null_ptr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl NewWithNullPtr for wire_cst_receive_payment_request {
|
||||||
|
fn new_with_null_ptr() -> Self {
|
||||||
|
Self {
|
||||||
|
description: core::ptr::null_mut(),
|
||||||
|
prepare_res: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Default for wire_cst_receive_payment_request {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new_with_null_ptr()
|
||||||
|
}
|
||||||
|
}
|
||||||
impl NewWithNullPtr for wire_cst_receive_payment_response {
|
impl NewWithNullPtr for wire_cst_receive_payment_response {
|
||||||
fn new_with_null_ptr() -> Self {
|
fn new_with_null_ptr() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -2588,7 +2618,7 @@ pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_pr
|
|||||||
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
||||||
port_: i64,
|
port_: i64,
|
||||||
that: usize,
|
that: usize,
|
||||||
req: *mut wire_cst_prepare_receive_request,
|
req: *mut wire_cst_prepare_receive_payment_request,
|
||||||
) {
|
) {
|
||||||
wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment_impl(port_, that, req)
|
wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment_impl(port_, that, req)
|
||||||
}
|
}
|
||||||
@@ -2624,7 +2654,7 @@ pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_re
|
|||||||
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
||||||
port_: i64,
|
port_: i64,
|
||||||
that: usize,
|
that: usize,
|
||||||
req: *mut wire_cst_prepare_receive_response,
|
req: *mut wire_cst_receive_payment_request,
|
||||||
) {
|
) {
|
||||||
wire__crate__bindings__BindingLiquidSdk_receive_payment_impl(port_, that, req)
|
wire__crate__bindings__BindingLiquidSdk_receive_payment_impl(port_, that, req)
|
||||||
}
|
}
|
||||||
@@ -2949,18 +2979,10 @@ pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchai
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request(
|
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request(
|
||||||
) -> *mut wire_cst_prepare_receive_request {
|
) -> *mut wire_cst_prepare_receive_payment_request {
|
||||||
flutter_rust_bridge::for_generated::new_leak_box_ptr(
|
flutter_rust_bridge::for_generated::new_leak_box_ptr(
|
||||||
wire_cst_prepare_receive_request::new_with_null_ptr(),
|
wire_cst_prepare_receive_payment_request::new_with_null_ptr(),
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response(
|
|
||||||
) -> *mut wire_cst_prepare_receive_response {
|
|
||||||
flutter_rust_bridge::for_generated::new_leak_box_ptr(
|
|
||||||
wire_cst_prepare_receive_response::new_with_null_ptr(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2988,6 +3010,14 @@ pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request(
|
||||||
|
) -> *mut wire_cst_receive_payment_request {
|
||||||
|
flutter_rust_bridge::for_generated::new_leak_box_ptr(
|
||||||
|
wire_cst_receive_payment_request::new_with_null_ptr(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_refund_request(
|
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_refund_request(
|
||||||
) -> *mut wire_cst_refund_request {
|
) -> *mut wire_cst_refund_request {
|
||||||
@@ -3766,6 +3796,7 @@ pub struct wire_cst_payment {
|
|||||||
fees_sat: u64,
|
fees_sat: u64,
|
||||||
preimage: *mut wire_cst_list_prim_u_8_strict,
|
preimage: *mut wire_cst_list_prim_u_8_strict,
|
||||||
bolt11: *mut wire_cst_list_prim_u_8_strict,
|
bolt11: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
description: *mut wire_cst_list_prim_u_8_strict,
|
||||||
refund_tx_id: *mut wire_cst_list_prim_u_8_strict,
|
refund_tx_id: *mut wire_cst_list_prim_u_8_strict,
|
||||||
refund_tx_amount_sat: *mut u64,
|
refund_tx_amount_sat: *mut u64,
|
||||||
payment_type: i32,
|
payment_type: i32,
|
||||||
@@ -3864,12 +3895,12 @@ pub struct wire_cst_prepare_receive_onchain_response {
|
|||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct wire_cst_prepare_receive_request {
|
pub struct wire_cst_prepare_receive_payment_request {
|
||||||
payer_amount_sat: u64,
|
payer_amount_sat: u64,
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct wire_cst_prepare_receive_response {
|
pub struct wire_cst_prepare_receive_payment_response {
|
||||||
payer_amount_sat: u64,
|
payer_amount_sat: u64,
|
||||||
fees_sat: u64,
|
fees_sat: u64,
|
||||||
}
|
}
|
||||||
@@ -3912,6 +3943,12 @@ pub struct wire_cst_receive_onchain_response {
|
|||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct wire_cst_receive_payment_request {
|
||||||
|
description: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
prepare_res: wire_cst_prepare_receive_payment_response,
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
pub struct wire_cst_receive_payment_response {
|
pub struct wire_cst_receive_payment_response {
|
||||||
id: *mut wire_cst_list_prim_u_8_strict,
|
id: *mut wire_cst_list_prim_u_8_strict,
|
||||||
invoice: *mut wire_cst_list_prim_u_8_strict,
|
invoice: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
|||||||
@@ -930,7 +930,7 @@ fn wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment_impl(
|
|||||||
that: impl CstDecode<
|
that: impl CstDecode<
|
||||||
RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BindingLiquidSdk>>,
|
RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BindingLiquidSdk>>,
|
||||||
>,
|
>,
|
||||||
req: impl CstDecode<crate::model::PrepareReceiveRequest>,
|
req: impl CstDecode<crate::model::PrepareReceivePaymentRequest>,
|
||||||
) {
|
) {
|
||||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||||
flutter_rust_bridge::for_generated::TaskInfo {
|
flutter_rust_bridge::for_generated::TaskInfo {
|
||||||
@@ -1126,7 +1126,7 @@ fn wire__crate__bindings__BindingLiquidSdk_receive_payment_impl(
|
|||||||
that: impl CstDecode<
|
that: impl CstDecode<
|
||||||
RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BindingLiquidSdk>>,
|
RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BindingLiquidSdk>>,
|
||||||
>,
|
>,
|
||||||
req: impl CstDecode<crate::model::PrepareReceiveResponse>,
|
req: impl CstDecode<crate::model::ReceivePaymentRequest>,
|
||||||
) {
|
) {
|
||||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||||
flutter_rust_bridge::for_generated::TaskInfo {
|
flutter_rust_bridge::for_generated::TaskInfo {
|
||||||
@@ -2941,6 +2941,7 @@ impl SseDecode for crate::model::Payment {
|
|||||||
let mut var_feesSat = <u64>::sse_decode(deserializer);
|
let mut var_feesSat = <u64>::sse_decode(deserializer);
|
||||||
let mut var_preimage = <Option<String>>::sse_decode(deserializer);
|
let mut var_preimage = <Option<String>>::sse_decode(deserializer);
|
||||||
let mut var_bolt11 = <Option<String>>::sse_decode(deserializer);
|
let mut var_bolt11 = <Option<String>>::sse_decode(deserializer);
|
||||||
|
let mut var_description = <String>::sse_decode(deserializer);
|
||||||
let mut var_refundTxId = <Option<String>>::sse_decode(deserializer);
|
let mut var_refundTxId = <Option<String>>::sse_decode(deserializer);
|
||||||
let mut var_refundTxAmountSat = <Option<u64>>::sse_decode(deserializer);
|
let mut var_refundTxAmountSat = <Option<u64>>::sse_decode(deserializer);
|
||||||
let mut var_paymentType = <crate::model::PaymentType>::sse_decode(deserializer);
|
let mut var_paymentType = <crate::model::PaymentType>::sse_decode(deserializer);
|
||||||
@@ -2953,6 +2954,7 @@ impl SseDecode for crate::model::Payment {
|
|||||||
fees_sat: var_feesSat,
|
fees_sat: var_feesSat,
|
||||||
preimage: var_preimage,
|
preimage: var_preimage,
|
||||||
bolt11: var_bolt11,
|
bolt11: var_bolt11,
|
||||||
|
description: var_description,
|
||||||
refund_tx_id: var_refundTxId,
|
refund_tx_id: var_refundTxId,
|
||||||
refund_tx_amount_sat: var_refundTxAmountSat,
|
refund_tx_amount_sat: var_refundTxAmountSat,
|
||||||
payment_type: var_paymentType,
|
payment_type: var_paymentType,
|
||||||
@@ -3141,22 +3143,22 @@ impl SseDecode for crate::model::PrepareReceiveOnchainResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SseDecode for crate::model::PrepareReceiveRequest {
|
impl SseDecode for crate::model::PrepareReceivePaymentRequest {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
let mut var_payerAmountSat = <u64>::sse_decode(deserializer);
|
let mut var_payerAmountSat = <u64>::sse_decode(deserializer);
|
||||||
return crate::model::PrepareReceiveRequest {
|
return crate::model::PrepareReceivePaymentRequest {
|
||||||
payer_amount_sat: var_payerAmountSat,
|
payer_amount_sat: var_payerAmountSat,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SseDecode for crate::model::PrepareReceiveResponse {
|
impl SseDecode for crate::model::PrepareReceivePaymentResponse {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
let mut var_payerAmountSat = <u64>::sse_decode(deserializer);
|
let mut var_payerAmountSat = <u64>::sse_decode(deserializer);
|
||||||
let mut var_feesSat = <u64>::sse_decode(deserializer);
|
let mut var_feesSat = <u64>::sse_decode(deserializer);
|
||||||
return crate::model::PrepareReceiveResponse {
|
return crate::model::PrepareReceivePaymentResponse {
|
||||||
payer_amount_sat: var_payerAmountSat,
|
payer_amount_sat: var_payerAmountSat,
|
||||||
fees_sat: var_feesSat,
|
fees_sat: var_feesSat,
|
||||||
};
|
};
|
||||||
@@ -3237,6 +3239,19 @@ impl SseDecode for crate::model::ReceiveOnchainResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseDecode for crate::model::ReceivePaymentRequest {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
|
let mut var_description = <Option<String>>::sse_decode(deserializer);
|
||||||
|
let mut var_prepareRes =
|
||||||
|
<crate::model::PrepareReceivePaymentResponse>::sse_decode(deserializer);
|
||||||
|
return crate::model::ReceivePaymentRequest {
|
||||||
|
description: var_description,
|
||||||
|
prepare_res: var_prepareRes,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseDecode for crate::model::ReceivePaymentResponse {
|
impl SseDecode for crate::model::ReceivePaymentResponse {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
@@ -4541,6 +4556,7 @@ impl flutter_rust_bridge::IntoDart for crate::model::Payment {
|
|||||||
self.fees_sat.into_into_dart().into_dart(),
|
self.fees_sat.into_into_dart().into_dart(),
|
||||||
self.preimage.into_into_dart().into_dart(),
|
self.preimage.into_into_dart().into_dart(),
|
||||||
self.bolt11.into_into_dart().into_dart(),
|
self.bolt11.into_into_dart().into_dart(),
|
||||||
|
self.description.into_into_dart().into_dart(),
|
||||||
self.refund_tx_id.into_into_dart().into_dart(),
|
self.refund_tx_id.into_into_dart().into_dart(),
|
||||||
self.refund_tx_amount_sat.into_into_dart().into_dart(),
|
self.refund_tx_amount_sat.into_into_dart().into_dart(),
|
||||||
self.payment_type.into_into_dart().into_dart(),
|
self.payment_type.into_into_dart().into_dart(),
|
||||||
@@ -4768,24 +4784,24 @@ impl flutter_rust_bridge::IntoIntoDart<crate::model::PrepareReceiveOnchainRespon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
impl flutter_rust_bridge::IntoDart for crate::model::PrepareReceiveRequest {
|
impl flutter_rust_bridge::IntoDart for crate::model::PrepareReceivePaymentRequest {
|
||||||
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||||
[self.payer_amount_sat.into_into_dart().into_dart()].into_dart()
|
[self.payer_amount_sat.into_into_dart().into_dart()].into_dart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
|
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
|
||||||
for crate::model::PrepareReceiveRequest
|
for crate::model::PrepareReceivePaymentRequest
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl flutter_rust_bridge::IntoIntoDart<crate::model::PrepareReceiveRequest>
|
impl flutter_rust_bridge::IntoIntoDart<crate::model::PrepareReceivePaymentRequest>
|
||||||
for crate::model::PrepareReceiveRequest
|
for crate::model::PrepareReceivePaymentRequest
|
||||||
{
|
{
|
||||||
fn into_into_dart(self) -> crate::model::PrepareReceiveRequest {
|
fn into_into_dart(self) -> crate::model::PrepareReceivePaymentRequest {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
impl flutter_rust_bridge::IntoDart for crate::model::PrepareReceiveResponse {
|
impl flutter_rust_bridge::IntoDart for crate::model::PrepareReceivePaymentResponse {
|
||||||
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||||
[
|
[
|
||||||
self.payer_amount_sat.into_into_dart().into_dart(),
|
self.payer_amount_sat.into_into_dart().into_dart(),
|
||||||
@@ -4795,13 +4811,13 @@ impl flutter_rust_bridge::IntoDart for crate::model::PrepareReceiveResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
|
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
|
||||||
for crate::model::PrepareReceiveResponse
|
for crate::model::PrepareReceivePaymentResponse
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl flutter_rust_bridge::IntoIntoDart<crate::model::PrepareReceiveResponse>
|
impl flutter_rust_bridge::IntoIntoDart<crate::model::PrepareReceivePaymentResponse>
|
||||||
for crate::model::PrepareReceiveResponse
|
for crate::model::PrepareReceivePaymentResponse
|
||||||
{
|
{
|
||||||
fn into_into_dart(self) -> crate::model::PrepareReceiveResponse {
|
fn into_into_dart(self) -> crate::model::PrepareReceivePaymentResponse {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4930,6 +4946,27 @@ impl flutter_rust_bridge::IntoIntoDart<crate::model::ReceiveOnchainResponse>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
|
impl flutter_rust_bridge::IntoDart for crate::model::ReceivePaymentRequest {
|
||||||
|
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||||
|
[
|
||||||
|
self.description.into_into_dart().into_dart(),
|
||||||
|
self.prepare_res.into_into_dart().into_dart(),
|
||||||
|
]
|
||||||
|
.into_dart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
|
||||||
|
for crate::model::ReceivePaymentRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
impl flutter_rust_bridge::IntoIntoDart<crate::model::ReceivePaymentRequest>
|
||||||
|
for crate::model::ReceivePaymentRequest
|
||||||
|
{
|
||||||
|
fn into_into_dart(self) -> crate::model::ReceivePaymentRequest {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
impl flutter_rust_bridge::IntoDart for crate::model::ReceivePaymentResponse {
|
impl flutter_rust_bridge::IntoDart for crate::model::ReceivePaymentResponse {
|
||||||
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||||
[
|
[
|
||||||
@@ -6075,6 +6112,7 @@ impl SseEncode for crate::model::Payment {
|
|||||||
<u64>::sse_encode(self.fees_sat, serializer);
|
<u64>::sse_encode(self.fees_sat, serializer);
|
||||||
<Option<String>>::sse_encode(self.preimage, serializer);
|
<Option<String>>::sse_encode(self.preimage, serializer);
|
||||||
<Option<String>>::sse_encode(self.bolt11, serializer);
|
<Option<String>>::sse_encode(self.bolt11, serializer);
|
||||||
|
<String>::sse_encode(self.description, serializer);
|
||||||
<Option<String>>::sse_encode(self.refund_tx_id, serializer);
|
<Option<String>>::sse_encode(self.refund_tx_id, serializer);
|
||||||
<Option<u64>>::sse_encode(self.refund_tx_amount_sat, serializer);
|
<Option<u64>>::sse_encode(self.refund_tx_amount_sat, serializer);
|
||||||
<crate::model::PaymentType>::sse_encode(self.payment_type, serializer);
|
<crate::model::PaymentType>::sse_encode(self.payment_type, serializer);
|
||||||
@@ -6241,14 +6279,14 @@ impl SseEncode for crate::model::PrepareReceiveOnchainResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SseEncode for crate::model::PrepareReceiveRequest {
|
impl SseEncode for crate::model::PrepareReceivePaymentRequest {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
<u64>::sse_encode(self.payer_amount_sat, serializer);
|
<u64>::sse_encode(self.payer_amount_sat, serializer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SseEncode for crate::model::PrepareReceiveResponse {
|
impl SseEncode for crate::model::PrepareReceivePaymentResponse {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
<u64>::sse_encode(self.payer_amount_sat, serializer);
|
<u64>::sse_encode(self.payer_amount_sat, serializer);
|
||||||
@@ -6305,6 +6343,14 @@ impl SseEncode for crate::model::ReceiveOnchainResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseEncode for crate::model::ReceivePaymentRequest {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
|
<Option<String>>::sse_encode(self.description, serializer);
|
||||||
|
<crate::model::PrepareReceivePaymentResponse>::sse_encode(self.prepare_res, serializer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseEncode for crate::model::ReceivePaymentResponse {
|
impl SseEncode for crate::model::ReceivePaymentResponse {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
//!
|
//!
|
||||||
//! // Set the amount you wish the payer to send, which should be within the above limits
|
//! // Set the amount you wish the payer to send, which should be within the above limits
|
||||||
//! let prepare_receive_response = sdk
|
//! let prepare_receive_response = sdk
|
||||||
//! .prepare_receive_payment(&PrepareReceiveRequest {
|
//! .prepare_receive_payment(&PrepareReceivePaymentRequest {
|
||||||
//! payer_amount_sat: 5_000,
|
//! payer_amount_sat: 5_000,
|
||||||
//! })
|
//! })
|
||||||
//! .await?;
|
//! .await?;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use boltz_client::network::Chain;
|
use boltz_client::network::Chain;
|
||||||
use boltz_client::swaps::boltzv2::{
|
use boltz_client::swaps::boltz::{
|
||||||
CreateChainResponse, CreateReverseResponse, CreateSubmarineResponse, Leaf, Side, SwapTree,
|
CreateChainResponse, CreateReverseResponse, CreateSubmarineResponse, Leaf, Side, SwapTree,
|
||||||
};
|
};
|
||||||
use boltz_client::{BtcSwapScriptV2, BtcSwapTxV2, Keypair, LBtcSwapScriptV2, LBtcSwapTxV2};
|
use boltz_client::{BtcSwapScript, BtcSwapTx, Keypair, LBtcSwapScript, LBtcSwapTx};
|
||||||
use lwk_wollet::ElementsNetwork;
|
use lwk_wollet::ElementsNetwork;
|
||||||
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
|
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
|
||||||
use rusqlite::ToSql;
|
use rusqlite::ToSql;
|
||||||
@@ -175,17 +175,24 @@ pub struct ConnectRequest {
|
|||||||
|
|
||||||
/// An argument when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
/// An argument when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct PrepareReceiveRequest {
|
pub struct PrepareReceivePaymentRequest {
|
||||||
pub payer_amount_sat: u64,
|
pub payer_amount_sat: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returned when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
/// Returned when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct PrepareReceiveResponse {
|
pub struct PrepareReceivePaymentResponse {
|
||||||
pub payer_amount_sat: u64,
|
pub payer_amount_sat: u64,
|
||||||
pub fees_sat: u64,
|
pub fees_sat: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An argument when calling [crate::sdk::LiquidSdk::receive_payment].
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub struct ReceivePaymentRequest {
|
||||||
|
pub description: Option<String>,
|
||||||
|
pub prepare_res: PrepareReceivePaymentResponse,
|
||||||
|
}
|
||||||
|
|
||||||
/// Returned when calling [crate::sdk::LiquidSdk::receive_payment].
|
/// Returned when calling [crate::sdk::LiquidSdk::receive_payment].
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct ReceivePaymentResponse {
|
pub struct ReceivePaymentResponse {
|
||||||
@@ -375,18 +382,18 @@ impl Swap {
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum SwapScriptV2 {
|
pub(crate) enum SwapScriptV2 {
|
||||||
Bitcoin(BtcSwapScriptV2),
|
Bitcoin(BtcSwapScript),
|
||||||
Liquid(LBtcSwapScriptV2),
|
Liquid(LBtcSwapScript),
|
||||||
}
|
}
|
||||||
impl SwapScriptV2 {
|
impl SwapScriptV2 {
|
||||||
pub(crate) fn as_bitcoin_script(&self) -> Result<BtcSwapScriptV2> {
|
pub(crate) fn as_bitcoin_script(&self) -> Result<BtcSwapScript> {
|
||||||
match self {
|
match self {
|
||||||
SwapScriptV2::Bitcoin(script) => Ok(script.clone()),
|
SwapScriptV2::Bitcoin(script) => Ok(script.clone()),
|
||||||
_ => Err(anyhow!("Invalid chain")),
|
_ => Err(anyhow!("Invalid chain")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn as_liquid_script(&self) -> Result<LBtcSwapScriptV2> {
|
pub(crate) fn as_liquid_script(&self) -> Result<LBtcSwapScript> {
|
||||||
match self {
|
match self {
|
||||||
SwapScriptV2::Liquid(script) => Ok(script.clone()),
|
SwapScriptV2::Liquid(script) => Ok(script.clone()),
|
||||||
_ => Err(anyhow!("Invalid chain")),
|
_ => Err(anyhow!("Invalid chain")),
|
||||||
@@ -396,18 +403,18 @@ impl SwapScriptV2 {
|
|||||||
|
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub(crate) enum SwapTxV2 {
|
pub(crate) enum SwapTxV2 {
|
||||||
Bitcoin(BtcSwapTxV2),
|
Bitcoin(BtcSwapTx),
|
||||||
Liquid(LBtcSwapTxV2),
|
Liquid(LBtcSwapTx),
|
||||||
}
|
}
|
||||||
impl SwapTxV2 {
|
impl SwapTxV2 {
|
||||||
pub(crate) fn as_bitcoin_tx(&self) -> Result<BtcSwapTxV2> {
|
pub(crate) fn as_bitcoin_tx(&self) -> Result<BtcSwapTx> {
|
||||||
match self {
|
match self {
|
||||||
SwapTxV2::Bitcoin(tx) => Ok(tx.clone()),
|
SwapTxV2::Bitcoin(tx) => Ok(tx.clone()),
|
||||||
_ => Err(anyhow!("Invalid chain")),
|
_ => Err(anyhow!("Invalid chain")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn as_liquid_tx(&self) -> Result<LBtcSwapTxV2> {
|
pub(crate) fn as_liquid_tx(&self) -> Result<LBtcSwapTx> {
|
||||||
match self {
|
match self {
|
||||||
SwapTxV2::Liquid(tx) => Ok(tx.clone()),
|
SwapTxV2::Liquid(tx) => Ok(tx.clone()),
|
||||||
_ => Err(anyhow!("Invalid chain")),
|
_ => Err(anyhow!("Invalid chain")),
|
||||||
@@ -447,6 +454,7 @@ pub(crate) struct ChainSwap {
|
|||||||
pub(crate) lockup_address: String,
|
pub(crate) lockup_address: String,
|
||||||
pub(crate) timeout_block_height: u32,
|
pub(crate) timeout_block_height: u32,
|
||||||
pub(crate) preimage: String,
|
pub(crate) preimage: String,
|
||||||
|
pub(crate) description: Option<String>,
|
||||||
pub(crate) payer_amount_sat: u64,
|
pub(crate) payer_amount_sat: u64,
|
||||||
pub(crate) receiver_amount_sat: u64,
|
pub(crate) receiver_amount_sat: u64,
|
||||||
pub(crate) claim_fees_sat: u64,
|
pub(crate) claim_fees_sat: u64,
|
||||||
@@ -492,12 +500,12 @@ impl ChainSwap {
|
|||||||
let chain_swap_details = self.get_boltz_create_response()?.claim_details;
|
let chain_swap_details = self.get_boltz_create_response()?.claim_details;
|
||||||
let our_pubkey = self.get_claim_keypair()?.public_key();
|
let our_pubkey = self.get_claim_keypair()?.public_key();
|
||||||
let swap_script = match self.direction {
|
let swap_script = match self.direction {
|
||||||
Direction::Incoming => SwapScriptV2::Liquid(LBtcSwapScriptV2::chain_from_swap_resp(
|
Direction::Incoming => SwapScriptV2::Liquid(LBtcSwapScript::chain_from_swap_resp(
|
||||||
Side::Claim,
|
Side::Claim,
|
||||||
chain_swap_details,
|
chain_swap_details,
|
||||||
our_pubkey.into(),
|
our_pubkey.into(),
|
||||||
)?),
|
)?),
|
||||||
Direction::Outgoing => SwapScriptV2::Bitcoin(BtcSwapScriptV2::chain_from_swap_resp(
|
Direction::Outgoing => SwapScriptV2::Bitcoin(BtcSwapScript::chain_from_swap_resp(
|
||||||
Side::Claim,
|
Side::Claim,
|
||||||
chain_swap_details,
|
chain_swap_details,
|
||||||
our_pubkey.into(),
|
our_pubkey.into(),
|
||||||
@@ -510,12 +518,12 @@ impl ChainSwap {
|
|||||||
let chain_swap_details = self.get_boltz_create_response()?.lockup_details;
|
let chain_swap_details = self.get_boltz_create_response()?.lockup_details;
|
||||||
let our_pubkey = self.get_refund_keypair()?.public_key();
|
let our_pubkey = self.get_refund_keypair()?.public_key();
|
||||||
let swap_script = match self.direction {
|
let swap_script = match self.direction {
|
||||||
Direction::Incoming => SwapScriptV2::Bitcoin(BtcSwapScriptV2::chain_from_swap_resp(
|
Direction::Incoming => SwapScriptV2::Bitcoin(BtcSwapScript::chain_from_swap_resp(
|
||||||
Side::Lockup,
|
Side::Lockup,
|
||||||
chain_swap_details,
|
chain_swap_details,
|
||||||
our_pubkey.into(),
|
our_pubkey.into(),
|
||||||
)?),
|
)?),
|
||||||
Direction::Outgoing => SwapScriptV2::Liquid(LBtcSwapScriptV2::chain_from_swap_resp(
|
Direction::Outgoing => SwapScriptV2::Liquid(LBtcSwapScript::chain_from_swap_resp(
|
||||||
Side::Lockup,
|
Side::Lockup,
|
||||||
chain_swap_details,
|
chain_swap_details,
|
||||||
our_pubkey.into(),
|
our_pubkey.into(),
|
||||||
@@ -550,6 +558,7 @@ impl ChainSwap {
|
|||||||
pub(crate) struct SendSwap {
|
pub(crate) struct SendSwap {
|
||||||
pub(crate) id: String,
|
pub(crate) id: String,
|
||||||
pub(crate) invoice: String,
|
pub(crate) invoice: String,
|
||||||
|
pub(crate) description: Option<String>,
|
||||||
pub(crate) preimage: Option<String>,
|
pub(crate) preimage: Option<String>,
|
||||||
pub(crate) payer_amount_sat: u64,
|
pub(crate) payer_amount_sat: u64,
|
||||||
pub(crate) receiver_amount_sat: u64,
|
pub(crate) receiver_amount_sat: u64,
|
||||||
@@ -583,14 +592,16 @@ impl SendSwap {
|
|||||||
&internal_create_response.claim_public_key,
|
&internal_create_response.claim_public_key,
|
||||||
)?,
|
)?,
|
||||||
expected_amount: internal_create_response.expected_amount,
|
expected_amount: internal_create_response.expected_amount,
|
||||||
|
referral_id: internal_create_response.referral_id,
|
||||||
swap_tree: internal_create_response.swap_tree.clone().into(),
|
swap_tree: internal_create_response.swap_tree.clone().into(),
|
||||||
|
timeout_block_height: internal_create_response.timeout_block_height,
|
||||||
blinding_key: internal_create_response.blinding_key.clone(),
|
blinding_key: internal_create_response.blinding_key.clone(),
|
||||||
};
|
};
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_swap_script(&self) -> Result<LBtcSwapScriptV2, PaymentError> {
|
pub(crate) fn get_swap_script(&self) -> Result<LBtcSwapScript, PaymentError> {
|
||||||
LBtcSwapScriptV2::submarine_from_swap_resp(
|
LBtcSwapScript::submarine_from_swap_resp(
|
||||||
&self.get_boltz_create_response()?,
|
&self.get_boltz_create_response()?,
|
||||||
self.get_refund_keypair()?.public_key().into(),
|
self.get_refund_keypair()?.public_key().into(),
|
||||||
)
|
)
|
||||||
@@ -632,6 +643,7 @@ pub(crate) struct ReceiveSwap {
|
|||||||
pub(crate) create_response_json: String,
|
pub(crate) create_response_json: String,
|
||||||
pub(crate) claim_private_key: String,
|
pub(crate) claim_private_key: String,
|
||||||
pub(crate) invoice: String,
|
pub(crate) invoice: String,
|
||||||
|
pub(crate) description: Option<String>,
|
||||||
/// The amount of the invoice
|
/// The amount of the invoice
|
||||||
pub(crate) payer_amount_sat: u64,
|
pub(crate) payer_amount_sat: u64,
|
||||||
pub(crate) receiver_amount_sat: u64,
|
pub(crate) receiver_amount_sat: u64,
|
||||||
@@ -671,7 +683,7 @@ impl ReceiveSwap {
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_swap_script(&self) -> Result<LBtcSwapScriptV2, PaymentError> {
|
pub(crate) fn get_swap_script(&self) -> Result<LBtcSwapScript, PaymentError> {
|
||||||
let keypair = self.get_claim_keypair()?;
|
let keypair = self.get_claim_keypair()?;
|
||||||
let create_response =
|
let create_response =
|
||||||
self.get_boltz_create_response()
|
self.get_boltz_create_response()
|
||||||
@@ -681,7 +693,7 @@ impl ReceiveSwap {
|
|||||||
self.id
|
self.id
|
||||||
),
|
),
|
||||||
})?;
|
})?;
|
||||||
LBtcSwapScriptV2::reverse_from_swap_resp(&create_response, keypair.public_key().into())
|
LBtcSwapScript::reverse_from_swap_resp(&create_response, keypair.public_key().into())
|
||||||
.map_err(|e| PaymentError::Generic {
|
.map_err(|e| PaymentError::Generic {
|
||||||
err: format!(
|
err: format!(
|
||||||
"Failed to create swap script for Receive Swap {}: {e:?}",
|
"Failed to create swap script for Receive Swap {}: {e:?}",
|
||||||
@@ -907,6 +919,8 @@ pub struct PaymentSwapData {
|
|||||||
|
|
||||||
pub bolt11: Option<String>,
|
pub bolt11: Option<String>,
|
||||||
|
|
||||||
|
pub description: String,
|
||||||
|
|
||||||
/// Amount sent by the swap payer
|
/// Amount sent by the swap payer
|
||||||
pub payer_amount_sat: u64,
|
pub payer_amount_sat: u64,
|
||||||
|
|
||||||
@@ -965,6 +979,9 @@ pub struct Payment {
|
|||||||
/// In the case of a Receive payment, this is the invoice paid by the user
|
/// In the case of a Receive payment, this is the invoice paid by the user
|
||||||
pub bolt11: Option<String>,
|
pub bolt11: Option<String>,
|
||||||
|
|
||||||
|
/// Represents the invoice description
|
||||||
|
pub description: String,
|
||||||
|
|
||||||
/// For a Send swap which was refunded, this is the refund tx id
|
/// For a Send swap which was refunded, this is the refund tx id
|
||||||
pub refund_tx_id: Option<String>,
|
pub refund_tx_id: Option<String>,
|
||||||
|
|
||||||
@@ -996,6 +1013,7 @@ impl Payment {
|
|||||||
fees_sat: swap.payer_amount_sat - swap.receiver_amount_sat,
|
fees_sat: swap.payer_amount_sat - swap.receiver_amount_sat,
|
||||||
preimage: swap.preimage,
|
preimage: swap.preimage,
|
||||||
bolt11: swap.bolt11,
|
bolt11: swap.bolt11,
|
||||||
|
description: swap.description,
|
||||||
refund_tx_id: swap.refund_tx_id,
|
refund_tx_id: swap.refund_tx_id,
|
||||||
refund_tx_amount_sat: swap.refund_tx_amount_sat,
|
refund_tx_amount_sat: swap.refund_tx_amount_sat,
|
||||||
payment_type,
|
payment_type,
|
||||||
@@ -1021,6 +1039,10 @@ impl Payment {
|
|||||||
},
|
},
|
||||||
preimage: swap.as_ref().and_then(|s| s.preimage.clone()),
|
preimage: swap.as_ref().and_then(|s| s.preimage.clone()),
|
||||||
bolt11: swap.as_ref().and_then(|s| s.bolt11.clone()),
|
bolt11: swap.as_ref().and_then(|s| s.bolt11.clone()),
|
||||||
|
description: swap
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| s.description.clone())
|
||||||
|
.unwrap_or("Liquid transfer".to_string()),
|
||||||
refund_tx_id: swap.as_ref().and_then(|s| s.refund_tx_id.clone()),
|
refund_tx_id: swap.as_ref().and_then(|s| s.refund_tx_id.clone()),
|
||||||
refund_tx_amount_sat: swap.as_ref().and_then(|s| s.refund_tx_amount_sat),
|
refund_tx_amount_sat: swap.as_ref().and_then(|s| s.refund_tx_amount_sat),
|
||||||
payment_type: tx.payment_type,
|
payment_type: tx.payment_type,
|
||||||
@@ -1165,3 +1187,18 @@ macro_rules! get_invoice_amount {
|
|||||||
/ 1000
|
/ 1000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! get_invoice_description {
|
||||||
|
($invoice:expr) => {
|
||||||
|
match $invoice
|
||||||
|
.trim()
|
||||||
|
.parse::<Bolt11Invoice>()
|
||||||
|
.expect("Expecting valid invoice")
|
||||||
|
.description()
|
||||||
|
{
|
||||||
|
Bolt11InvoiceDescription::Direct(msg) => Some(msg.to_string()),
|
||||||
|
Bolt11InvoiceDescription::Hash(_) => None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use boltz_client::swaps::boltzv2::{ChainSwapDetails, CreateChainResponse};
|
use boltz_client::swaps::boltz::{ChainSwapDetails, CreateChainResponse};
|
||||||
use rusqlite::{named_params, params, Connection, Row};
|
use rusqlite::{named_params, params, Connection, Row};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ impl Persister {
|
|||||||
con.execute(
|
con.execute(
|
||||||
"UPDATE chain_swaps
|
"UPDATE chain_swaps
|
||||||
SET
|
SET
|
||||||
|
description = :description,
|
||||||
server_lockup_tx_id = :server_lockup_tx_id,
|
server_lockup_tx_id = :server_lockup_tx_id,
|
||||||
user_lockup_tx_id = :user_lockup_tx_id,
|
user_lockup_tx_id = :user_lockup_tx_id,
|
||||||
claim_tx_id = :claim_tx_id,
|
claim_tx_id = :claim_tx_id,
|
||||||
@@ -66,6 +67,7 @@ impl Persister {
|
|||||||
id = :id",
|
id = :id",
|
||||||
named_params! {
|
named_params! {
|
||||||
":id": &chain_swap.id,
|
":id": &chain_swap.id,
|
||||||
|
":description": &chain_swap.description,
|
||||||
":server_lockup_tx_id": &chain_swap.server_lockup_tx_id,
|
":server_lockup_tx_id": &chain_swap.server_lockup_tx_id,
|
||||||
":user_lockup_tx_id": &chain_swap.user_lockup_tx_id,
|
":user_lockup_tx_id": &chain_swap.user_lockup_tx_id,
|
||||||
":claim_tx_id": &chain_swap.claim_tx_id,
|
":claim_tx_id": &chain_swap.claim_tx_id,
|
||||||
@@ -92,6 +94,7 @@ impl Persister {
|
|||||||
lockup_address,
|
lockup_address,
|
||||||
timeout_block_height,
|
timeout_block_height,
|
||||||
preimage,
|
preimage,
|
||||||
|
description,
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat,
|
receiver_amount_sat,
|
||||||
accept_zero_conf,
|
accept_zero_conf,
|
||||||
@@ -139,19 +142,20 @@ impl Persister {
|
|||||||
lockup_address: row.get(3)?,
|
lockup_address: row.get(3)?,
|
||||||
timeout_block_height: row.get(4)?,
|
timeout_block_height: row.get(4)?,
|
||||||
preimage: row.get(5)?,
|
preimage: row.get(5)?,
|
||||||
payer_amount_sat: row.get(6)?,
|
description: row.get(6)?,
|
||||||
receiver_amount_sat: row.get(7)?,
|
payer_amount_sat: row.get(7)?,
|
||||||
accept_zero_conf: row.get(8)?,
|
receiver_amount_sat: row.get(8)?,
|
||||||
create_response_json: row.get(9)?,
|
accept_zero_conf: row.get(9)?,
|
||||||
claim_private_key: row.get(10)?,
|
create_response_json: row.get(10)?,
|
||||||
refund_private_key: row.get(11)?,
|
claim_private_key: row.get(11)?,
|
||||||
server_lockup_tx_id: row.get(12)?,
|
refund_private_key: row.get(12)?,
|
||||||
user_lockup_tx_id: row.get(13)?,
|
server_lockup_tx_id: row.get(13)?,
|
||||||
claim_fees_sat: row.get(14)?,
|
user_lockup_tx_id: row.get(14)?,
|
||||||
claim_tx_id: row.get(15)?,
|
claim_fees_sat: row.get(15)?,
|
||||||
refund_tx_id: row.get(16)?,
|
claim_tx_id: row.get(16)?,
|
||||||
created_at: row.get(17)?,
|
refund_tx_id: row.get(17)?,
|
||||||
state: row.get(18)?,
|
created_at: row.get(18)?,
|
||||||
|
state: row.get(19)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,5 +60,10 @@ pub(crate) fn current_migrations() -> Vec<&'static str> {
|
|||||||
key TEXT NOT NULL PRIMARY KEY,
|
key TEXT NOT NULL PRIMARY KEY,
|
||||||
value TEXT NOT NULL
|
value TEXT NOT NULL
|
||||||
) STRICT;",
|
) STRICT;",
|
||||||
|
"
|
||||||
|
ALTER TABLE receive_swaps ADD COLUMN description TEXT;
|
||||||
|
ALTER TABLE send_swaps ADD COLUMN description TEXT;
|
||||||
|
ALTER TABLE chain_swaps ADD COLUMN description TEXT;
|
||||||
|
",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ pub(crate) mod send;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::{fs::create_dir_all, path::PathBuf, str::FromStr};
|
use std::{fs::create_dir_all, path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
|
use crate::lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription};
|
||||||
|
use crate::model::{LiquidNetwork::*, *};
|
||||||
|
use crate::{get_invoice_description, utils};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use migrations::current_migrations;
|
use migrations::current_migrations;
|
||||||
use rusqlite::{params, Connection, OptionalExtension, Row};
|
use rusqlite::{params, Connection, OptionalExtension, Row};
|
||||||
use rusqlite_migration::{Migrations, M};
|
use rusqlite_migration::{Migrations, M};
|
||||||
|
|
||||||
use crate::model::{LiquidNetwork::*, *};
|
|
||||||
use crate::utils;
|
|
||||||
|
|
||||||
pub(crate) struct Persister {
|
pub(crate) struct Persister {
|
||||||
main_db_dir: PathBuf,
|
main_db_dir: PathBuf,
|
||||||
network: LiquidNetwork,
|
network: LiquidNetwork,
|
||||||
@@ -155,12 +155,14 @@ impl Persister {
|
|||||||
rs.id,
|
rs.id,
|
||||||
rs.created_at,
|
rs.created_at,
|
||||||
rs.invoice,
|
rs.invoice,
|
||||||
|
rs.description,
|
||||||
rs.payer_amount_sat,
|
rs.payer_amount_sat,
|
||||||
rs.receiver_amount_sat,
|
rs.receiver_amount_sat,
|
||||||
rs.state,
|
rs.state,
|
||||||
ss.id,
|
ss.id,
|
||||||
ss.created_at,
|
ss.created_at,
|
||||||
ss.invoice,
|
ss.invoice,
|
||||||
|
ss.description,
|
||||||
ss.preimage,
|
ss.preimage,
|
||||||
ss.refund_tx_id,
|
ss.refund_tx_id,
|
||||||
ss.payer_amount_sat,
|
ss.payer_amount_sat,
|
||||||
@@ -170,6 +172,7 @@ impl Persister {
|
|||||||
cs.created_at,
|
cs.created_at,
|
||||||
cs.direction,
|
cs.direction,
|
||||||
cs.preimage,
|
cs.preimage,
|
||||||
|
cs.description,
|
||||||
cs.refund_tx_id,
|
cs.refund_tx_id,
|
||||||
cs.payer_amount_sat,
|
cs.payer_amount_sat,
|
||||||
cs.receiver_amount_sat,
|
cs.receiver_amount_sat,
|
||||||
@@ -220,29 +223,32 @@ impl Persister {
|
|||||||
let maybe_receive_swap_id: Option<String> = row.get(6)?;
|
let maybe_receive_swap_id: Option<String> = row.get(6)?;
|
||||||
let maybe_receive_swap_created_at: Option<u32> = row.get(7)?;
|
let maybe_receive_swap_created_at: Option<u32> = row.get(7)?;
|
||||||
let maybe_receive_swap_invoice: Option<String> = row.get(8)?;
|
let maybe_receive_swap_invoice: Option<String> = row.get(8)?;
|
||||||
let maybe_receive_swap_payer_amount_sat: Option<u64> = row.get(9)?;
|
let maybe_receive_swap_description: Option<String> = row.get(9)?;
|
||||||
let maybe_receive_swap_receiver_amount_sat: Option<u64> = row.get(10)?;
|
let maybe_receive_swap_payer_amount_sat: Option<u64> = row.get(10)?;
|
||||||
let maybe_receive_swap_receiver_state: Option<PaymentState> = row.get(11)?;
|
let maybe_receive_swap_receiver_amount_sat: Option<u64> = row.get(11)?;
|
||||||
|
let maybe_receive_swap_receiver_state: Option<PaymentState> = row.get(12)?;
|
||||||
|
|
||||||
let maybe_send_swap_id: Option<String> = row.get(12)?;
|
let maybe_send_swap_id: Option<String> = row.get(13)?;
|
||||||
let maybe_send_swap_created_at: Option<u32> = row.get(13)?;
|
let maybe_send_swap_created_at: Option<u32> = row.get(14)?;
|
||||||
let maybe_send_swap_invoice: Option<String> = row.get(14)?;
|
let maybe_send_swap_invoice: Option<String> = row.get(15)?;
|
||||||
let maybe_send_swap_preimage: Option<String> = row.get(15)?;
|
let maybe_send_swap_description: Option<String> = row.get(16)?;
|
||||||
let maybe_send_swap_refund_tx_id: Option<String> = row.get(16)?;
|
let maybe_send_swap_preimage: Option<String> = row.get(17)?;
|
||||||
let maybe_send_swap_payer_amount_sat: Option<u64> = row.get(17)?;
|
let maybe_send_swap_refund_tx_id: Option<String> = row.get(18)?;
|
||||||
let maybe_send_swap_receiver_amount_sat: Option<u64> = row.get(18)?;
|
let maybe_send_swap_payer_amount_sat: Option<u64> = row.get(19)?;
|
||||||
let maybe_send_swap_state: Option<PaymentState> = row.get(19)?;
|
let maybe_send_swap_receiver_amount_sat: Option<u64> = row.get(20)?;
|
||||||
|
let maybe_send_swap_state: Option<PaymentState> = row.get(21)?;
|
||||||
|
|
||||||
let maybe_chain_swap_id: Option<String> = row.get(20)?;
|
let maybe_chain_swap_id: Option<String> = row.get(22)?;
|
||||||
let maybe_chain_swap_created_at: Option<u32> = row.get(21)?;
|
let maybe_chain_swap_created_at: Option<u32> = row.get(23)?;
|
||||||
let maybe_chain_swap_direction: Option<Direction> = row.get(22)?;
|
let maybe_chain_swap_direction: Option<Direction> = row.get(24)?;
|
||||||
let maybe_chain_swap_preimage: Option<String> = row.get(23)?;
|
let maybe_chain_swap_preimage: Option<String> = row.get(25)?;
|
||||||
let maybe_chain_swap_refund_tx_id: Option<String> = row.get(24)?;
|
let maybe_chain_swap_description: Option<String> = row.get(26)?;
|
||||||
let maybe_chain_swap_payer_amount_sat: Option<u64> = row.get(25)?;
|
let maybe_chain_swap_refund_tx_id: Option<String> = row.get(27)?;
|
||||||
let maybe_chain_swap_receiver_amount_sat: Option<u64> = row.get(26)?;
|
let maybe_chain_swap_payer_amount_sat: Option<u64> = row.get(28)?;
|
||||||
let maybe_chain_swap_state: Option<PaymentState> = row.get(27)?;
|
let maybe_chain_swap_receiver_amount_sat: Option<u64> = row.get(29)?;
|
||||||
|
let maybe_chain_swap_state: Option<PaymentState> = row.get(30)?;
|
||||||
|
|
||||||
let maybe_swap_refund_tx_amount_sat: Option<u64> = row.get(28)?;
|
let maybe_swap_refund_tx_amount_sat: Option<u64> = row.get(31)?;
|
||||||
|
|
||||||
let (swap, payment_type) = match maybe_receive_swap_id {
|
let (swap, payment_type) = match maybe_receive_swap_id {
|
||||||
Some(receive_swap_id) => (
|
Some(receive_swap_id) => (
|
||||||
@@ -250,7 +256,12 @@ impl Persister {
|
|||||||
swap_id: receive_swap_id,
|
swap_id: receive_swap_id,
|
||||||
created_at: maybe_receive_swap_created_at.unwrap_or(utils::now()),
|
created_at: maybe_receive_swap_created_at.unwrap_or(utils::now()),
|
||||||
preimage: None,
|
preimage: None,
|
||||||
bolt11: maybe_receive_swap_invoice,
|
bolt11: maybe_receive_swap_invoice.clone(),
|
||||||
|
description: maybe_receive_swap_description.unwrap_or_else(|| {
|
||||||
|
maybe_receive_swap_invoice
|
||||||
|
.and_then(|bolt11| get_invoice_description!(bolt11))
|
||||||
|
.unwrap_or("Lightning payment".to_string())
|
||||||
|
}),
|
||||||
payer_amount_sat: maybe_receive_swap_payer_amount_sat.unwrap_or(0),
|
payer_amount_sat: maybe_receive_swap_payer_amount_sat.unwrap_or(0),
|
||||||
receiver_amount_sat: maybe_receive_swap_receiver_amount_sat.unwrap_or(0),
|
receiver_amount_sat: maybe_receive_swap_receiver_amount_sat.unwrap_or(0),
|
||||||
refund_tx_id: None,
|
refund_tx_id: None,
|
||||||
@@ -265,7 +276,12 @@ impl Persister {
|
|||||||
swap_id: send_swap_id,
|
swap_id: send_swap_id,
|
||||||
created_at: maybe_send_swap_created_at.unwrap_or(utils::now()),
|
created_at: maybe_send_swap_created_at.unwrap_or(utils::now()),
|
||||||
preimage: maybe_send_swap_preimage,
|
preimage: maybe_send_swap_preimage,
|
||||||
bolt11: maybe_send_swap_invoice,
|
bolt11: maybe_send_swap_invoice.clone(),
|
||||||
|
description: maybe_send_swap_description.unwrap_or_else(|| {
|
||||||
|
maybe_send_swap_invoice
|
||||||
|
.and_then(|bolt11| get_invoice_description!(bolt11))
|
||||||
|
.unwrap_or("Lightning payment".to_string())
|
||||||
|
}),
|
||||||
payer_amount_sat: maybe_send_swap_payer_amount_sat.unwrap_or(0),
|
payer_amount_sat: maybe_send_swap_payer_amount_sat.unwrap_or(0),
|
||||||
receiver_amount_sat: maybe_send_swap_receiver_amount_sat.unwrap_or(0),
|
receiver_amount_sat: maybe_send_swap_receiver_amount_sat.unwrap_or(0),
|
||||||
refund_tx_id: maybe_send_swap_refund_tx_id,
|
refund_tx_id: maybe_send_swap_refund_tx_id,
|
||||||
@@ -281,6 +297,8 @@ impl Persister {
|
|||||||
created_at: maybe_chain_swap_created_at.unwrap_or(utils::now()),
|
created_at: maybe_chain_swap_created_at.unwrap_or(utils::now()),
|
||||||
preimage: maybe_chain_swap_preimage,
|
preimage: maybe_chain_swap_preimage,
|
||||||
bolt11: None,
|
bolt11: None,
|
||||||
|
description: maybe_chain_swap_description
|
||||||
|
.unwrap_or("Bitcoin transfer".to_string()),
|
||||||
payer_amount_sat: maybe_chain_swap_payer_amount_sat.unwrap_or(0),
|
payer_amount_sat: maybe_chain_swap_payer_amount_sat.unwrap_or(0),
|
||||||
receiver_amount_sat: maybe_chain_swap_receiver_amount_sat.unwrap_or(0),
|
receiver_amount_sat: maybe_chain_swap_receiver_amount_sat.unwrap_or(0),
|
||||||
refund_tx_id: maybe_chain_swap_refund_tx_id,
|
refund_tx_id: maybe_chain_swap_refund_tx_id,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use boltz_client::swaps::boltzv2::CreateReverseResponse;
|
use boltz_client::swaps::boltz::CreateReverseResponse;
|
||||||
use rusqlite::{named_params, params, Connection, Row};
|
use rusqlite::{named_params, params, Connection, Row};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ impl Persister {
|
|||||||
create_response_json,
|
create_response_json,
|
||||||
claim_private_key,
|
claim_private_key,
|
||||||
invoice,
|
invoice,
|
||||||
|
description,
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat,
|
receiver_amount_sat,
|
||||||
created_at,
|
created_at,
|
||||||
@@ -29,7 +30,7 @@ impl Persister {
|
|||||||
claim_tx_id,
|
claim_tx_id,
|
||||||
state
|
state
|
||||||
)
|
)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
)?;
|
)?;
|
||||||
_ = stmt.execute((
|
_ = stmt.execute((
|
||||||
&receive_swap.id,
|
&receive_swap.id,
|
||||||
@@ -37,6 +38,7 @@ impl Persister {
|
|||||||
&receive_swap.create_response_json,
|
&receive_swap.create_response_json,
|
||||||
&receive_swap.claim_private_key,
|
&receive_swap.claim_private_key,
|
||||||
&receive_swap.invoice,
|
&receive_swap.invoice,
|
||||||
|
&receive_swap.description,
|
||||||
&receive_swap.payer_amount_sat,
|
&receive_swap.payer_amount_sat,
|
||||||
&receive_swap.receiver_amount_sat,
|
&receive_swap.receiver_amount_sat,
|
||||||
&receive_swap.created_at,
|
&receive_swap.created_at,
|
||||||
@@ -63,6 +65,7 @@ impl Persister {
|
|||||||
rs.create_response_json,
|
rs.create_response_json,
|
||||||
rs.claim_private_key,
|
rs.claim_private_key,
|
||||||
rs.invoice,
|
rs.invoice,
|
||||||
|
rs.description,
|
||||||
rs.payer_amount_sat,
|
rs.payer_amount_sat,
|
||||||
rs.receiver_amount_sat,
|
rs.receiver_amount_sat,
|
||||||
rs.claim_fees_sat,
|
rs.claim_fees_sat,
|
||||||
@@ -102,12 +105,13 @@ impl Persister {
|
|||||||
create_response_json: row.get(2)?,
|
create_response_json: row.get(2)?,
|
||||||
claim_private_key: row.get(3)?,
|
claim_private_key: row.get(3)?,
|
||||||
invoice: row.get(4)?,
|
invoice: row.get(4)?,
|
||||||
payer_amount_sat: row.get(5)?,
|
description: row.get(5)?,
|
||||||
receiver_amount_sat: row.get(6)?,
|
payer_amount_sat: row.get(6)?,
|
||||||
claim_fees_sat: row.get(7)?,
|
receiver_amount_sat: row.get(7)?,
|
||||||
claim_tx_id: row.get(8)?,
|
claim_fees_sat: row.get(8)?,
|
||||||
created_at: row.get(9)?,
|
claim_tx_id: row.get(9)?,
|
||||||
state: row.get(10)?,
|
created_at: row.get(10)?,
|
||||||
|
state: row.get(11)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use boltz_client::swaps::boltzv2::CreateSubmarineResponse;
|
use boltz_client::swaps::boltz::CreateSubmarineResponse;
|
||||||
use rusqlite::{named_params, params, Connection, Row};
|
use rusqlite::{named_params, params, Connection, Row};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ impl Persister {
|
|||||||
INSERT INTO send_swaps (
|
INSERT INTO send_swaps (
|
||||||
id,
|
id,
|
||||||
invoice,
|
invoice,
|
||||||
|
description,
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat,
|
receiver_amount_sat,
|
||||||
create_response_json,
|
create_response_json,
|
||||||
@@ -28,11 +29,12 @@ impl Persister {
|
|||||||
created_at,
|
created_at,
|
||||||
state
|
state
|
||||||
)
|
)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
)?;
|
)?;
|
||||||
_ = stmt.execute((
|
_ = stmt.execute((
|
||||||
&send_swap.id,
|
&send_swap.id,
|
||||||
&send_swap.invoice,
|
&send_swap.invoice,
|
||||||
|
&send_swap.description,
|
||||||
&send_swap.payer_amount_sat,
|
&send_swap.payer_amount_sat,
|
||||||
&send_swap.receiver_amount_sat,
|
&send_swap.receiver_amount_sat,
|
||||||
&send_swap.create_response_json,
|
&send_swap.create_response_json,
|
||||||
@@ -81,6 +83,7 @@ impl Persister {
|
|||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
invoice,
|
invoice,
|
||||||
|
description,
|
||||||
preimage,
|
preimage,
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat,
|
receiver_amount_sat,
|
||||||
@@ -117,15 +120,16 @@ impl Persister {
|
|||||||
Ok(SendSwap {
|
Ok(SendSwap {
|
||||||
id: row.get(0)?,
|
id: row.get(0)?,
|
||||||
invoice: row.get(1)?,
|
invoice: row.get(1)?,
|
||||||
preimage: row.get(2)?,
|
description: row.get(2)?,
|
||||||
payer_amount_sat: row.get(3)?,
|
preimage: row.get(3)?,
|
||||||
receiver_amount_sat: row.get(4)?,
|
payer_amount_sat: row.get(4)?,
|
||||||
create_response_json: row.get(5)?,
|
receiver_amount_sat: row.get(5)?,
|
||||||
refund_private_key: row.get(6)?,
|
create_response_json: row.get(6)?,
|
||||||
lockup_tx_id: row.get(7)?,
|
refund_private_key: row.get(7)?,
|
||||||
refund_tx_id: row.get(8)?,
|
lockup_tx_id: row.get(8)?,
|
||||||
created_at: row.get(9)?,
|
refund_tx_id: row.get(9)?,
|
||||||
state: row.get(10)?,
|
created_at: row.get(10)?,
|
||||||
|
state: row.get(11)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +247,10 @@ pub(crate) struct InternalCreateSubmarineResponse {
|
|||||||
pub(crate) bip21: String,
|
pub(crate) bip21: String,
|
||||||
pub(crate) claim_public_key: String,
|
pub(crate) claim_public_key: String,
|
||||||
pub(crate) expected_amount: u64,
|
pub(crate) expected_amount: u64,
|
||||||
|
pub(crate) referral_id: Option<String>,
|
||||||
pub(crate) swap_tree: InternalSwapTree,
|
pub(crate) swap_tree: InternalSwapTree,
|
||||||
|
#[serde(default)]
|
||||||
|
pub(crate) timeout_block_height: u64,
|
||||||
pub(crate) blinding_key: Option<String>,
|
pub(crate) blinding_key: Option<String>,
|
||||||
}
|
}
|
||||||
impl InternalCreateSubmarineResponse {
|
impl InternalCreateSubmarineResponse {
|
||||||
@@ -264,7 +271,9 @@ impl InternalCreateSubmarineResponse {
|
|||||||
bip21: boltz_create_response.bip21.clone(),
|
bip21: boltz_create_response.bip21.clone(),
|
||||||
claim_public_key: boltz_create_response.claim_public_key.to_string(),
|
claim_public_key: boltz_create_response.claim_public_key.to_string(),
|
||||||
expected_amount: boltz_create_response.expected_amount,
|
expected_amount: boltz_create_response.expected_amount,
|
||||||
|
referral_id: boltz_create_response.referral_id.clone(),
|
||||||
swap_tree: boltz_create_response.swap_tree.clone().into(),
|
swap_tree: boltz_create_response.swap_tree.clone().into(),
|
||||||
|
timeout_block_height: boltz_create_response.timeout_block_height,
|
||||||
blinding_key: boltz_create_response.blinding_key.clone(),
|
blinding_key: boltz_create_response.blinding_key.clone(),
|
||||||
};
|
};
|
||||||
Ok(res)
|
Ok(res)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::{str::FromStr, sync::Arc};
|
|||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use boltz_client::swaps::boltz::RevSwapStates;
|
use boltz_client::swaps::boltz::RevSwapStates;
|
||||||
use boltz_client::swaps::boltzv2::{self, SwapUpdateTxDetails};
|
use boltz_client::swaps::boltz::{self, SwapUpdateTxDetails};
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use tokio::sync::{broadcast, Mutex};
|
use tokio::sync::{broadcast, Mutex};
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ impl ReceiveSwapStateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handles status updates from Boltz for Receive swaps
|
/// Handles status updates from Boltz for Receive swaps
|
||||||
pub(crate) async fn on_new_status(&self, update: &boltzv2::Update) -> Result<()> {
|
pub(crate) async fn on_new_status(&self, update: &boltz::Update) -> Result<()> {
|
||||||
let id = &update.id;
|
let id = &update.id;
|
||||||
let swap_state = &update.status;
|
let swap_state = &update.status;
|
||||||
let receive_swap = self
|
let receive_swap = self
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::{fs, path::PathBuf, str::FromStr, sync::Arc, time::Duration};
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use boltz_client::{swaps::boltzv2::*, util::secrets::Preimage, Bolt11Invoice};
|
use boltz_client::{swaps::boltz::*, util::secrets::Preimage};
|
||||||
use boltz_client::{LockTime, ToHex};
|
use boltz_client::{LockTime, ToHex};
|
||||||
use buy::{BuyBitcoinApi, BuyBitcoinService};
|
use buy::{BuyBitcoinApi, BuyBitcoinService};
|
||||||
use chain::bitcoin::HybridBitcoinChainService;
|
use chain::bitcoin::HybridBitcoinChainService;
|
||||||
@@ -28,6 +28,7 @@ use url::Url;
|
|||||||
use crate::chain::bitcoin::BitcoinChainService;
|
use crate::chain::bitcoin::BitcoinChainService;
|
||||||
use crate::chain_swap::ChainSwapStateHandler;
|
use crate::chain_swap::ChainSwapStateHandler;
|
||||||
use crate::error::SdkError;
|
use crate::error::SdkError;
|
||||||
|
use crate::lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription};
|
||||||
use crate::model::PaymentState::*;
|
use crate::model::PaymentState::*;
|
||||||
use crate::receive_swap::ReceiveSwapStateHandler;
|
use crate::receive_swap::ReceiveSwapStateHandler;
|
||||||
use crate::send_swap::SendSwapStateHandler;
|
use crate::send_swap::SendSwapStateHandler;
|
||||||
@@ -841,11 +842,13 @@ impl LiquidSdk {
|
|||||||
let swap_id = &create_response.id;
|
let swap_id = &create_response.id;
|
||||||
let create_response_json =
|
let create_response_json =
|
||||||
SendSwap::from_boltz_struct_to_json(&create_response, swap_id)?;
|
SendSwap::from_boltz_struct_to_json(&create_response, swap_id)?;
|
||||||
|
let description = get_invoice_description!(req.invoice);
|
||||||
|
|
||||||
let payer_amount_sat = req.fees_sat + receiver_amount_sat;
|
let payer_amount_sat = req.fees_sat + receiver_amount_sat;
|
||||||
let swap = SendSwap {
|
let swap = SendSwap {
|
||||||
id: swap_id.clone(),
|
id: swap_id.clone(),
|
||||||
invoice: req.invoice.clone(),
|
invoice: req.invoice.clone(),
|
||||||
|
description,
|
||||||
preimage: None,
|
preimage: None,
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat,
|
receiver_amount_sat,
|
||||||
@@ -1054,6 +1057,7 @@ impl LiquidSdk {
|
|||||||
lockup_address: create_response.lockup_details.lockup_address,
|
lockup_address: create_response.lockup_details.lockup_address,
|
||||||
timeout_block_height: create_response.lockup_details.timeout_block_height,
|
timeout_block_height: create_response.lockup_details.timeout_block_height,
|
||||||
preimage: preimage_str,
|
preimage: preimage_str,
|
||||||
|
description: Some("Bitcoin transfer".to_string()),
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat,
|
receiver_amount_sat,
|
||||||
claim_fees_sat,
|
claim_fees_sat,
|
||||||
@@ -1135,12 +1139,12 @@ impl LiquidSdk {
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `req` - the [PrepareReceiveRequest] containing:
|
/// * `req` - the [PrepareReceivePaymentRequest] containing:
|
||||||
/// * `payer_amount_sat` - the amount in satoshis to be paid by the payer
|
/// * `payer_amount_sat` - the amount in satoshis to be paid by the payer
|
||||||
pub async fn prepare_receive_payment(
|
pub async fn prepare_receive_payment(
|
||||||
&self,
|
&self,
|
||||||
req: &PrepareReceiveRequest,
|
req: &PrepareReceivePaymentRequest,
|
||||||
) -> Result<PrepareReceiveResponse, PaymentError> {
|
) -> Result<PrepareReceivePaymentResponse, PaymentError> {
|
||||||
self.ensure_is_started().await?;
|
self.ensure_is_started().await?;
|
||||||
let reverse_pair = self
|
let reverse_pair = self
|
||||||
.swapper
|
.swapper
|
||||||
@@ -1159,7 +1163,7 @@ impl LiquidSdk {
|
|||||||
|
|
||||||
debug!("Preparing Receive Swap with: payer_amount_sat {payer_amount_sat} sat, fees_sat {fees_sat} sat");
|
debug!("Preparing Receive Swap with: payer_amount_sat {payer_amount_sat} sat, fees_sat {fees_sat} sat");
|
||||||
|
|
||||||
Ok(PrepareReceiveResponse {
|
Ok(PrepareReceivePaymentResponse {
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
fees_sat,
|
fees_sat,
|
||||||
})
|
})
|
||||||
@@ -1169,7 +1173,9 @@ impl LiquidSdk {
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `req` - The [PrepareReceiveResponse] from calling [LiquidSdk::prepare_receive_payment]
|
/// * `req` - the [ReceivePaymentRequest] containing:
|
||||||
|
/// * `description` - the optional payment description
|
||||||
|
/// * `prepare_res` - the [PrepareReceivePaymentResponse] from calling [LiquidSdk::prepare_receive_payment]
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
@@ -1177,18 +1183,18 @@ impl LiquidSdk {
|
|||||||
/// * `invoice` - the bolt11 Lightning invoice that should be paid
|
/// * `invoice` - the bolt11 Lightning invoice that should be paid
|
||||||
pub async fn receive_payment(
|
pub async fn receive_payment(
|
||||||
&self,
|
&self,
|
||||||
req: &PrepareReceiveResponse,
|
req: &ReceivePaymentRequest,
|
||||||
) -> Result<ReceivePaymentResponse, PaymentError> {
|
) -> Result<ReceivePaymentResponse, PaymentError> {
|
||||||
self.ensure_is_started().await?;
|
self.ensure_is_started().await?;
|
||||||
|
|
||||||
let payer_amount_sat = req.payer_amount_sat;
|
let payer_amount_sat = req.prepare_res.payer_amount_sat;
|
||||||
let fees_sat = req.fees_sat;
|
let fees_sat = req.prepare_res.fees_sat;
|
||||||
|
|
||||||
let reverse_pair = self
|
let reverse_pair = self
|
||||||
.swapper
|
.swapper
|
||||||
.get_reverse_swap_pairs()?
|
.get_reverse_swap_pairs()?
|
||||||
.ok_or(PaymentError::PairsNotFound)?;
|
.ok_or(PaymentError::PairsNotFound)?;
|
||||||
let new_fees_sat = reverse_pair.fees.total(req.payer_amount_sat);
|
let new_fees_sat = reverse_pair.fees.total(payer_amount_sat);
|
||||||
ensure_sdk!(fees_sat == new_fees_sat, PaymentError::InvalidOrExpiredFees);
|
ensure_sdk!(fees_sat == new_fees_sat, PaymentError::InvalidOrExpiredFees);
|
||||||
|
|
||||||
debug!("Creating Receive Swap with: payer_amount_sat {payer_amount_sat} sat, fees_sat {fees_sat} sat");
|
debug!("Creating Receive Swap with: payer_amount_sat {payer_amount_sat} sat, fees_sat {fees_sat} sat");
|
||||||
@@ -1208,11 +1214,12 @@ impl LiquidSdk {
|
|||||||
let mrh_addr_hash_sig = keypair.sign_schnorr(mrh_addr_hash.into());
|
let mrh_addr_hash_sig = keypair.sign_schnorr(mrh_addr_hash.into());
|
||||||
|
|
||||||
let v2_req = CreateReverseRequest {
|
let v2_req = CreateReverseRequest {
|
||||||
invoice_amount: req.payer_amount_sat as u32, // TODO update our model
|
invoice_amount: payer_amount_sat as u32, // TODO update our model
|
||||||
from: "BTC".to_string(),
|
from: "BTC".to_string(),
|
||||||
to: "L-BTC".to_string(),
|
to: "L-BTC".to_string(),
|
||||||
preimage_hash: preimage.sha256,
|
preimage_hash: preimage.sha256,
|
||||||
claim_public_key: keypair.public_key().into(),
|
claim_public_key: keypair.public_key().into(),
|
||||||
|
description: req.description.clone(),
|
||||||
address: Some(mrh_addr_str.clone()),
|
address: Some(mrh_addr_str.clone()),
|
||||||
address_signature: Some(mrh_addr_hash_sig.to_hex()),
|
address_signature: Some(mrh_addr_hash_sig.to_hex()),
|
||||||
referral_id: None,
|
referral_id: None,
|
||||||
@@ -1230,7 +1237,7 @@ impl LiquidSdk {
|
|||||||
PaymentError::receive_error("Invoice has incorrect address in MRH")
|
PaymentError::receive_error("Invoice has incorrect address in MRH")
|
||||||
);
|
);
|
||||||
// The swap fee savings are passed on to the Sender: MRH amount = invoice amount - fees
|
// The swap fee savings are passed on to the Sender: MRH amount = invoice amount - fees
|
||||||
let expected_bip21_amount_sat = req.payer_amount_sat - req.fees_sat;
|
let expected_bip21_amount_sat = payer_amount_sat - fees_sat;
|
||||||
ensure_sdk!(
|
ensure_sdk!(
|
||||||
received_bip21_amount_sat == expected_bip21_amount_sat,
|
received_bip21_amount_sat == expected_bip21_amount_sat,
|
||||||
PaymentError::receive_error(&format!(
|
PaymentError::receive_error(&format!(
|
||||||
@@ -1265,6 +1272,10 @@ impl LiquidSdk {
|
|||||||
&swap_id,
|
&swap_id,
|
||||||
&invoice.to_string(),
|
&invoice.to_string(),
|
||||||
)?;
|
)?;
|
||||||
|
let description = match invoice.description() {
|
||||||
|
Bolt11InvoiceDescription::Direct(msg) => Some(msg.to_string()),
|
||||||
|
Bolt11InvoiceDescription::Hash(_) => None,
|
||||||
|
};
|
||||||
self.persister
|
self.persister
|
||||||
.insert_receive_swap(&ReceiveSwap {
|
.insert_receive_swap(&ReceiveSwap {
|
||||||
id: swap_id.clone(),
|
id: swap_id.clone(),
|
||||||
@@ -1272,8 +1283,9 @@ impl LiquidSdk {
|
|||||||
create_response_json,
|
create_response_json,
|
||||||
claim_private_key: keypair.display_secret().to_string(),
|
claim_private_key: keypair.display_secret().to_string(),
|
||||||
invoice: invoice.to_string(),
|
invoice: invoice.to_string(),
|
||||||
|
description,
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat: payer_amount_sat - req.fees_sat,
|
receiver_amount_sat: payer_amount_sat - fees_sat,
|
||||||
claim_fees_sat: reverse_pair.fees.claim_estimate(),
|
claim_fees_sat: reverse_pair.fees.claim_estimate(),
|
||||||
claim_tx_id: None,
|
claim_tx_id: None,
|
||||||
created_at: utils::now(),
|
created_at: utils::now(),
|
||||||
@@ -1365,6 +1377,7 @@ impl LiquidSdk {
|
|||||||
lockup_address: create_response.lockup_details.lockup_address,
|
lockup_address: create_response.lockup_details.lockup_address,
|
||||||
timeout_block_height: create_response.lockup_details.timeout_block_height,
|
timeout_block_height: create_response.lockup_details.timeout_block_height,
|
||||||
preimage: preimage_str,
|
preimage: preimage_str,
|
||||||
|
description: Some("Bitcoin transfer".to_string()),
|
||||||
payer_amount_sat,
|
payer_amount_sat,
|
||||||
receiver_amount_sat,
|
receiver_amount_sat,
|
||||||
claim_fees_sat,
|
claim_fees_sat,
|
||||||
@@ -1754,14 +1767,19 @@ impl LiquidSdk {
|
|||||||
&self,
|
&self,
|
||||||
req: LnUrlWithdrawRequest,
|
req: LnUrlWithdrawRequest,
|
||||||
) -> Result<LnUrlWithdrawResult, LnUrlWithdrawError> {
|
) -> Result<LnUrlWithdrawResult, LnUrlWithdrawError> {
|
||||||
let prepare_receive_res = self
|
let prepare_res = self
|
||||||
.prepare_receive_payment(&{
|
.prepare_receive_payment(&{
|
||||||
PrepareReceiveRequest {
|
PrepareReceivePaymentRequest {
|
||||||
payer_amount_sat: req.amount_msat / 1_000,
|
payer_amount_sat: req.amount_msat / 1_000,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
let receive_res = self.receive_payment(&prepare_receive_res).await?;
|
let receive_res = self
|
||||||
|
.receive_payment(&ReceivePaymentRequest {
|
||||||
|
prepare_res,
|
||||||
|
description: None,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
let invoice = parse_invoice(&receive_res.invoice)?;
|
let invoice = parse_invoice(&receive_res.invoice)?;
|
||||||
|
|
||||||
let res = validate_lnurl_withdraw(req.data, invoice).await?;
|
let res = validate_lnurl_withdraw(req.data, invoice).await?;
|
||||||
@@ -1897,7 +1915,7 @@ mod tests {
|
|||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use boltz_client::{
|
use boltz_client::{
|
||||||
boltzv2::{self, SwapUpdateTxDetails},
|
boltz::{self, SwapUpdateTxDetails},
|
||||||
swaps::boltz::{ChainSwapStates, RevSwapStates, SubSwapStates},
|
swaps::boltz::{ChainSwapStates, RevSwapStates, SubSwapStates},
|
||||||
};
|
};
|
||||||
use lwk_wollet::hashes::hex::DisplayHex;
|
use lwk_wollet::hashes::hex::DisplayHex;
|
||||||
@@ -1992,7 +2010,7 @@ mod tests {
|
|||||||
|
|
||||||
$status_stream
|
$status_stream
|
||||||
.clone()
|
.clone()
|
||||||
.send_mock_update(boltzv2::Update {
|
.send_mock_update(boltz::Update {
|
||||||
id: swap.id(),
|
id: swap.id(),
|
||||||
status: $status.to_string(),
|
status: $status.to_string(),
|
||||||
transaction: $transaction,
|
transaction: $transaction,
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use std::time::Duration;
|
|||||||
use std::{str::FromStr, sync::Arc};
|
use std::{str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use boltz_client::swaps::boltzv2;
|
use boltz_client::swaps::boltz;
|
||||||
use boltz_client::swaps::{boltz::SubSwapStates, boltzv2::CreateSubmarineResponse};
|
use boltz_client::swaps::{boltz::CreateSubmarineResponse, boltz::SubSwapStates};
|
||||||
use boltz_client::util::secrets::Preimage;
|
use boltz_client::util::secrets::Preimage;
|
||||||
use boltz_client::{Bolt11Invoice, ToHex};
|
use boltz_client::{Bolt11Invoice, ToHex};
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
@@ -63,7 +63,7 @@ impl SendSwapStateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handles status updates from Boltz for Send swaps
|
/// Handles status updates from Boltz for Send swaps
|
||||||
pub(crate) async fn on_new_status(&self, update: &boltzv2::Update) -> Result<()> {
|
pub(crate) async fn on_new_status(&self, update: &boltz::Update) -> Result<()> {
|
||||||
let id = &update.id;
|
let id = &update.id;
|
||||||
let swap_state = &update.status;
|
let swap_state = &update.status;
|
||||||
let swap = self
|
let swap = self
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use boltz_client::swaps::boltzv2::{self, Subscription, SwapUpdate};
|
use boltz_client::swaps::boltz::{self, Subscription, SwapUpdate};
|
||||||
use futures_util::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
@@ -18,13 +18,13 @@ use super::{ReconnectHandler, SwapperStatusStream};
|
|||||||
pub(crate) struct BoltzStatusStream {
|
pub(crate) struct BoltzStatusStream {
|
||||||
url: String,
|
url: String,
|
||||||
subscription_notifier: broadcast::Sender<String>,
|
subscription_notifier: broadcast::Sender<String>,
|
||||||
update_notifier: broadcast::Sender<boltzv2::Update>,
|
update_notifier: broadcast::Sender<boltz::Update>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BoltzStatusStream {
|
impl BoltzStatusStream {
|
||||||
pub(crate) fn new(url: &str) -> Self {
|
pub(crate) fn new(url: &str) -> Self {
|
||||||
let (subscription_notifier, _) = broadcast::channel::<String>(30);
|
let (subscription_notifier, _) = broadcast::channel::<String>(30);
|
||||||
let (update_notifier, _) = broadcast::channel::<boltzv2::Update>(30);
|
let (update_notifier, _) = broadcast::channel::<boltz::Update>(30);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
url: url.replace("http", "ws") + "/ws",
|
url: url.replace("http", "ws") + "/ws",
|
||||||
@@ -65,7 +65,7 @@ impl SwapperStatusStream for BoltzStatusStream {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscribe_swap_updates(&self) -> broadcast::Receiver<boltzv2::Update> {
|
fn subscribe_swap_updates(&self) -> broadcast::Receiver<boltz::Update> {
|
||||||
self.update_notifier.subscribe()
|
self.update_notifier.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ use boltz_client::elements::secp256k1_zkp::{MusigPartialSignature, MusigPubNonce
|
|||||||
use boltz_client::error::Error;
|
use boltz_client::error::Error;
|
||||||
use boltz_client::network::electrum::ElectrumConfig;
|
use boltz_client::network::electrum::ElectrumConfig;
|
||||||
use boltz_client::network::Chain;
|
use boltz_client::network::Chain;
|
||||||
use boltz_client::swaps::boltzv2::{
|
use boltz_client::swaps::boltz::{
|
||||||
self, BoltzApiClientV2, ChainPair, Cooperative, CreateChainRequest, CreateChainResponse,
|
self, BoltzApiClientV2, ChainPair, Cooperative, CreateChainRequest, CreateChainResponse,
|
||||||
CreateReverseRequest, CreateReverseResponse, CreateSubmarineRequest, CreateSubmarineResponse,
|
CreateReverseRequest, CreateReverseResponse, CreateSubmarineRequest, CreateSubmarineResponse,
|
||||||
ReversePair, SubmarineClaimTxResponse, SubmarinePair, BOLTZ_MAINNET_URL_V2,
|
ReversePair, SubmarineClaimTxResponse, SubmarinePair, BOLTZ_MAINNET_URL_V2,
|
||||||
BOLTZ_TESTNET_URL_V2,
|
BOLTZ_TESTNET_URL_V2,
|
||||||
};
|
};
|
||||||
use boltz_client::util::secrets::Preimage;
|
use boltz_client::util::secrets::Preimage;
|
||||||
use boltz_client::{Amount, Bolt11Invoice, BtcSwapTxV2, Keypair, LBtcSwapTxV2, LockTime};
|
use boltz_client::{Amount, Bolt11Invoice, BtcSwapTx, Keypair, LBtcSwapTx, LockTime};
|
||||||
use boltz_status_stream::BoltzStatusStream;
|
use boltz_status_stream::BoltzStatusStream;
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use lwk_wollet::elements;
|
use lwk_wollet::elements;
|
||||||
@@ -43,7 +43,7 @@ pub trait SwapperStatusStream: Send + Sync {
|
|||||||
shutdown: watch::Receiver<()>,
|
shutdown: watch::Receiver<()>,
|
||||||
);
|
);
|
||||||
fn track_swap_id(&self, swap_id: &str) -> Result<()>;
|
fn track_swap_id(&self, swap_id: &str) -> Result<()>;
|
||||||
fn subscribe_swap_updates(&self) -> broadcast::Receiver<boltzv2::Update>;
|
fn subscribe_swap_updates(&self) -> broadcast::Receiver<boltz::Update>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Swapper: Send + Sync {
|
pub trait Swapper: Send + Sync {
|
||||||
@@ -222,12 +222,12 @@ impl BoltzSwapper {
|
|||||||
refund_address: &String,
|
refund_address: &String,
|
||||||
) -> Result<SwapTxV2, SdkError> {
|
) -> Result<SwapTxV2, SdkError> {
|
||||||
let swap_tx = match swap_script {
|
let swap_tx = match swap_script {
|
||||||
SwapScriptV2::Bitcoin(swap_script) => SwapTxV2::Bitcoin(BtcSwapTxV2::new_refund(
|
SwapScriptV2::Bitcoin(swap_script) => SwapTxV2::Bitcoin(BtcSwapTx::new_refund(
|
||||||
swap_script.clone(),
|
swap_script.clone(),
|
||||||
refund_address,
|
refund_address,
|
||||||
&self.bitcoin_electrum_config,
|
&self.bitcoin_electrum_config,
|
||||||
)?),
|
)?),
|
||||||
SwapScriptV2::Liquid(swap_script) => SwapTxV2::Liquid(LBtcSwapTxV2::new_refund(
|
SwapScriptV2::Liquid(swap_script) => SwapTxV2::Liquid(LBtcSwapTx::new_refund(
|
||||||
swap_script.clone(),
|
swap_script.clone(),
|
||||||
refund_address,
|
refund_address,
|
||||||
&self.liquid_electrum_config,
|
&self.liquid_electrum_config,
|
||||||
@@ -293,7 +293,7 @@ impl BoltzSwapper {
|
|||||||
fn claim_outgoing_chain_swap(&self, swap: &ChainSwap) -> Result<String, PaymentError> {
|
fn claim_outgoing_chain_swap(&self, swap: &ChainSwap) -> Result<String, PaymentError> {
|
||||||
let claim_keypair = swap.get_claim_keypair()?;
|
let claim_keypair = swap.get_claim_keypair()?;
|
||||||
let claim_swap_script = swap.get_claim_swap_script()?.as_bitcoin_script()?;
|
let claim_swap_script = swap.get_claim_swap_script()?.as_bitcoin_script()?;
|
||||||
let claim_tx_wrapper = BtcSwapTxV2::new_claim(
|
let claim_tx_wrapper = BtcSwapTx::new_claim(
|
||||||
claim_swap_script,
|
claim_swap_script,
|
||||||
swap.claim_address.clone(),
|
swap.claim_address.clone(),
|
||||||
&self.bitcoin_electrum_config,
|
&self.bitcoin_electrum_config,
|
||||||
@@ -323,7 +323,7 @@ impl BoltzSwapper {
|
|||||||
fn claim_incoming_chain_swap(&self, swap: &ChainSwap) -> Result<String, PaymentError> {
|
fn claim_incoming_chain_swap(&self, swap: &ChainSwap) -> Result<String, PaymentError> {
|
||||||
let claim_keypair = swap.get_claim_keypair()?;
|
let claim_keypair = swap.get_claim_keypair()?;
|
||||||
let swap_script = swap.get_claim_swap_script()?.as_liquid_script()?;
|
let swap_script = swap.get_claim_swap_script()?.as_liquid_script()?;
|
||||||
let claim_tx_wrapper = LBtcSwapTxV2::new_claim(
|
let claim_tx_wrapper = LBtcSwapTx::new_claim(
|
||||||
swap_script,
|
swap_script,
|
||||||
swap.claim_address.clone(),
|
swap.claim_address.clone(),
|
||||||
&self.liquid_electrum_config,
|
&self.liquid_electrum_config,
|
||||||
@@ -710,7 +710,7 @@ impl Swapper for BoltzSwapper {
|
|||||||
) -> Result<String, PaymentError> {
|
) -> Result<String, PaymentError> {
|
||||||
let swap_script = swap.get_swap_script()?;
|
let swap_script = swap.get_swap_script()?;
|
||||||
let swap_id = &swap.id;
|
let swap_id = &swap.id;
|
||||||
let claim_tx_wrapper = LBtcSwapTxV2::new_claim(
|
let claim_tx_wrapper = LBtcSwapTx::new_claim(
|
||||||
swap_script,
|
swap_script,
|
||||||
claim_address,
|
claim_address,
|
||||||
&self.liquid_electrum_config,
|
&self.liquid_electrum_config,
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ pub(crate) fn new_chain_swap(
|
|||||||
lockup_address: "tb1p7cftn5u3ndt8ln0m6hruwyhsz8kc5sxt557ua03qcew0z29u5paqh8f7uu".to_string(),
|
lockup_address: "tb1p7cftn5u3ndt8ln0m6hruwyhsz8kc5sxt557ua03qcew0z29u5paqh8f7uu".to_string(),
|
||||||
timeout_block_height: 2868778,
|
timeout_block_height: 2868778,
|
||||||
preimage: "bbce422d96c0386c3a6c1b1fe11fc7be3fdd871c6855db6ab2e319e96ec19c78".to_string(),
|
preimage: "bbce422d96c0386c3a6c1b1fe11fc7be3fdd871c6855db6ab2e319e96ec19c78".to_string(),
|
||||||
|
description: Some("Bitcoin transfer".to_string()),
|
||||||
create_response_json: r#"{
|
create_response_json: r#"{
|
||||||
"claim_details": {
|
"claim_details": {
|
||||||
"swapTree": {
|
"swapTree": {
|
||||||
@@ -119,6 +120,7 @@ pub(crate) fn new_chain_swap(
|
|||||||
lockup_address: "tlq1pqg4e5r5a59gdl26ud6s7gna3mchqs20ycwl2lp67ejzy69fl7dwccwx9nqtr6ef848k7vpmvmdhsyeq2wp3vtn3gnlenhd0wrasv4qvr2dk0nz5tu0rw".to_string(),
|
lockup_address: "tlq1pqg4e5r5a59gdl26ud6s7gna3mchqs20ycwl2lp67ejzy69fl7dwccwx9nqtr6ef848k7vpmvmdhsyeq2wp3vtn3gnlenhd0wrasv4qvr2dk0nz5tu0rw".to_string(),
|
||||||
timeout_block_height: 1481523,
|
timeout_block_height: 1481523,
|
||||||
preimage: "a95a028483df6112c15fdef513d9d8255ff0951d5c0856f85cf9c98352a0f71a".to_string(),
|
preimage: "a95a028483df6112c15fdef513d9d8255ff0951d5c0856f85cf9c98352a0f71a".to_string(),
|
||||||
|
description: Some("Bitcoin transfer".to_string()),
|
||||||
create_response_json: r#"{
|
create_response_json: r#"{
|
||||||
"claim_details": {
|
"claim_details": {
|
||||||
"swapTree":{
|
"swapTree":{
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ pub(crate) fn new_send_swap(payment_state: Option<PaymentState>) -> SendSwap {
|
|||||||
SendSwap {
|
SendSwap {
|
||||||
id: generate_random_string(4),
|
id: generate_random_string(4),
|
||||||
invoice: invoice.to_string(),
|
invoice: invoice.to_string(),
|
||||||
|
description: Some("Send to BTC lightning".to_string()),
|
||||||
preimage: None,
|
preimage: None,
|
||||||
payer_amount_sat: 1149,
|
payer_amount_sat: 1149,
|
||||||
receiver_amount_sat: 1000,
|
receiver_amount_sat: 1000,
|
||||||
@@ -60,6 +61,7 @@ pub(crate) fn new_send_swap(payment_state: Option<PaymentState>) -> SendSwap {
|
|||||||
"version": 196
|
"version": 196
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"timeout_block_height": 1459611,
|
||||||
"blinding_key": "1eabe70f75a3c92e1ce1e4108a014a275a4b03415234c87d8670e29d70059326"
|
"blinding_key": "1eabe70f75a3c92e1ce1e4108a014a275a4b03415234c87d8670e29d70059326"
|
||||||
}"#.to_string(),
|
}"#.to_string(),
|
||||||
lockup_tx_id: None,
|
lockup_tx_id: None,
|
||||||
@@ -74,6 +76,7 @@ pub(crate) fn new_receive_swap(payment_state: Option<PaymentState>) -> ReceiveSw
|
|||||||
ReceiveSwap {
|
ReceiveSwap {
|
||||||
id: generate_random_string(4),
|
id: generate_random_string(4),
|
||||||
preimage: "49ef4cb865d78519e5b3cf6aae6b409e1b471fe8ddbda744582e23665a2252cf".to_string(),
|
preimage: "49ef4cb865d78519e5b3cf6aae6b409e1b471fe8ddbda744582e23665a2252cf".to_string(),
|
||||||
|
description: Some("Send to L-BTC address".to_string()),
|
||||||
create_response_json: r#"{
|
create_response_json: r#"{
|
||||||
"swap_tree": {
|
"swap_tree": {
|
||||||
"claim_leaf": {
|
"claim_leaf": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use boltz_client::boltzv2;
|
use boltz_client::boltz;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::{broadcast, watch};
|
use tokio::sync::{broadcast, watch};
|
||||||
@@ -10,17 +10,17 @@ use tokio::sync::{broadcast, watch};
|
|||||||
use crate::swapper::{ReconnectHandler, SwapperStatusStream};
|
use crate::swapper::{ReconnectHandler, SwapperStatusStream};
|
||||||
|
|
||||||
pub(crate) struct MockStatusStream {
|
pub(crate) struct MockStatusStream {
|
||||||
pub update_notifier: broadcast::Sender<boltzv2::Update>,
|
pub update_notifier: broadcast::Sender<boltz::Update>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MockStatusStream {
|
impl MockStatusStream {
|
||||||
pub(crate) fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
let (update_notifier, _) = broadcast::channel::<boltzv2::Update>(30);
|
let (update_notifier, _) = broadcast::channel::<boltz::Update>(30);
|
||||||
|
|
||||||
Self { update_notifier }
|
Self { update_notifier }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn send_mock_update(self: Arc<Self>, update: boltzv2::Update) -> Result<()> {
|
pub(crate) async fn send_mock_update(self: Arc<Self>, update: boltz::Update) -> Result<()> {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
self.update_notifier.send(update).unwrap();
|
self.update_notifier.send(update).unwrap();
|
||||||
})
|
})
|
||||||
@@ -42,7 +42,7 @@ impl SwapperStatusStream for MockStatusStream {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscribe_swap_updates(&self) -> broadcast::Receiver<boltzv2::Update> {
|
fn subscribe_swap_updates(&self) -> broadcast::Receiver<boltz::Update> {
|
||||||
self.update_notifier.subscribe()
|
self.update_notifier.subscribe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
|
|
||||||
use boltz_client::{
|
use boltz_client::{
|
||||||
boltzv2::{
|
boltz::{
|
||||||
ChainFees, ChainMinerFees, ChainPair, ChainSwapDetails, CreateChainResponse,
|
ChainFees, ChainMinerFees, ChainPair, ChainSwapDetails, CreateChainResponse,
|
||||||
CreateReverseResponse, CreateSubmarineResponse, Leaf, PairLimits, PairMinerFees,
|
CreateReverseResponse, CreateSubmarineResponse, Leaf, PairLimits, PairMinerFees,
|
||||||
ReverseFees, ReverseLimits, ReversePair, SubmarineClaimTxResponse, SubmarineFees,
|
ReverseFees, ReverseLimits, ReversePair, SubmarineClaimTxResponse, SubmarineFees,
|
||||||
@@ -65,7 +65,7 @@ impl MockSwapper {
|
|||||||
impl Swapper for MockSwapper {
|
impl Swapper for MockSwapper {
|
||||||
fn create_chain_swap(
|
fn create_chain_swap(
|
||||||
&self,
|
&self,
|
||||||
_req: boltz_client::swaps::boltzv2::CreateChainRequest,
|
_req: boltz_client::swaps::boltz::CreateChainRequest,
|
||||||
) -> Result<CreateChainResponse, PaymentError> {
|
) -> Result<CreateChainResponse, PaymentError> {
|
||||||
Ok(CreateChainResponse {
|
Ok(CreateChainResponse {
|
||||||
id: generate_random_string(4),
|
id: generate_random_string(4),
|
||||||
@@ -76,7 +76,7 @@ impl Swapper for MockSwapper {
|
|||||||
|
|
||||||
fn create_send_swap(
|
fn create_send_swap(
|
||||||
&self,
|
&self,
|
||||||
req: boltz_client::swaps::boltzv2::CreateSubmarineRequest,
|
req: boltz_client::swaps::boltz::CreateSubmarineRequest,
|
||||||
) -> Result<CreateSubmarineResponse, PaymentError> {
|
) -> Result<CreateSubmarineResponse, PaymentError> {
|
||||||
let invoice = parse_invoice(&req.invoice).map_err(|err| PaymentError::InvalidInvoice {
|
let invoice = parse_invoice(&req.invoice).map_err(|err| PaymentError::InvalidInvoice {
|
||||||
err: err.to_string(),
|
err: err.to_string(),
|
||||||
@@ -94,7 +94,9 @@ impl Swapper for MockSwapper {
|
|||||||
claim_public_key: Self::mock_public_key(),
|
claim_public_key: Self::mock_public_key(),
|
||||||
expected_amount: amount_msat / 1000,
|
expected_amount: amount_msat / 1000,
|
||||||
id: generate_random_string(4),
|
id: generate_random_string(4),
|
||||||
|
referral_id: None,
|
||||||
swap_tree: Self::mock_swap_tree(),
|
swap_tree: Self::mock_swap_tree(),
|
||||||
|
timeout_block_height: 1459611,
|
||||||
blinding_key: None,
|
blinding_key: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -231,7 +233,7 @@ impl Swapper for MockSwapper {
|
|||||||
fn claim_send_swap_cooperative(
|
fn claim_send_swap_cooperative(
|
||||||
&self,
|
&self,
|
||||||
_swap: &SendSwap,
|
_swap: &SendSwap,
|
||||||
_claim_tx_response: boltz_client::swaps::boltzv2::SubmarineClaimTxResponse,
|
_claim_tx_response: boltz_client::swaps::boltz::SubmarineClaimTxResponse,
|
||||||
_refund_address: &str,
|
_refund_address: &str,
|
||||||
) -> Result<(), PaymentError> {
|
) -> Result<(), PaymentError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -239,7 +241,7 @@ impl Swapper for MockSwapper {
|
|||||||
|
|
||||||
fn create_receive_swap(
|
fn create_receive_swap(
|
||||||
&self,
|
&self,
|
||||||
_req: boltz_client::swaps::boltzv2::CreateReverseRequest,
|
_req: boltz_client::swaps::boltz::CreateReverseRequest,
|
||||||
) -> Result<CreateReverseResponse, PaymentError> {
|
) -> Result<CreateReverseResponse, PaymentError> {
|
||||||
Ok(CreateReverseResponse {
|
Ok(CreateReverseResponse {
|
||||||
id: generate_random_string(4),
|
id: generate_random_string(4),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use crate::prelude::{
|
|||||||
STANDARD_FEE_RATE_SAT_PER_VBYTE,
|
STANDARD_FEE_RATE_SAT_PER_VBYTE,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use boltz_client::boltzv2::{
|
use boltz_client::boltz::{
|
||||||
BoltzApiClientV2, Cooperative, BOLTZ_MAINNET_URL_V2, BOLTZ_TESTNET_URL_V2,
|
BoltzApiClientV2, Cooperative, BOLTZ_MAINNET_URL_V2, BOLTZ_TESTNET_URL_V2,
|
||||||
};
|
};
|
||||||
use boltz_client::network::electrum::ElectrumConfig;
|
use boltz_client::network::electrum::ElectrumConfig;
|
||||||
@@ -73,7 +73,7 @@ pub(crate) fn estimate_refund_fees(
|
|||||||
true,
|
true,
|
||||||
100,
|
100,
|
||||||
);
|
);
|
||||||
let swap_tx = boltz_client::LBtcSwapTxV2::new_refund(
|
let swap_tx = boltz_client::LBtcSwapTx::new_refund(
|
||||||
swap_script,
|
swap_script,
|
||||||
&output_address.to_string(),
|
&output_address.to_string(),
|
||||||
&electrum_config,
|
&electrum_config,
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ abstract class BindingLiquidSdk implements RustOpaqueInterface {
|
|||||||
|
|
||||||
Future<PrepareReceiveOnchainResponse> prepareReceiveOnchain({required PrepareReceiveOnchainRequest req});
|
Future<PrepareReceiveOnchainResponse> prepareReceiveOnchain({required PrepareReceiveOnchainRequest req});
|
||||||
|
|
||||||
Future<PrepareReceiveResponse> prepareReceivePayment({required PrepareReceiveRequest req});
|
Future<PrepareReceivePaymentResponse> prepareReceivePayment({required PrepareReceivePaymentRequest req});
|
||||||
|
|
||||||
Future<PrepareRefundResponse> prepareRefund({required PrepareRefundRequest req});
|
Future<PrepareRefundResponse> prepareRefund({required PrepareRefundRequest req});
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ abstract class BindingLiquidSdk implements RustOpaqueInterface {
|
|||||||
|
|
||||||
Future<ReceiveOnchainResponse> receiveOnchain({required PrepareReceiveOnchainResponse req});
|
Future<ReceiveOnchainResponse> receiveOnchain({required PrepareReceiveOnchainResponse req});
|
||||||
|
|
||||||
Future<ReceivePaymentResponse> receivePayment({required PrepareReceiveResponse req});
|
Future<ReceivePaymentResponse> receivePayment({required ReceivePaymentRequest req});
|
||||||
|
|
||||||
Future<RecommendedFees> recommendedFees();
|
Future<RecommendedFees> recommendedFees();
|
||||||
|
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ abstract class RustLibApi extends BaseApi {
|
|||||||
Future<PrepareReceiveOnchainResponse> crateBindingsBindingLiquidSdkPrepareReceiveOnchain(
|
Future<PrepareReceiveOnchainResponse> crateBindingsBindingLiquidSdkPrepareReceiveOnchain(
|
||||||
{required BindingLiquidSdk that, required PrepareReceiveOnchainRequest req});
|
{required BindingLiquidSdk that, required PrepareReceiveOnchainRequest req});
|
||||||
|
|
||||||
Future<PrepareReceiveResponse> crateBindingsBindingLiquidSdkPrepareReceivePayment(
|
Future<PrepareReceivePaymentResponse> crateBindingsBindingLiquidSdkPrepareReceivePayment(
|
||||||
{required BindingLiquidSdk that, required PrepareReceiveRequest req});
|
{required BindingLiquidSdk that, required PrepareReceivePaymentRequest req});
|
||||||
|
|
||||||
Future<PrepareRefundResponse> crateBindingsBindingLiquidSdkPrepareRefund(
|
Future<PrepareRefundResponse> crateBindingsBindingLiquidSdkPrepareRefund(
|
||||||
{required BindingLiquidSdk that, required PrepareRefundRequest req});
|
{required BindingLiquidSdk that, required PrepareRefundRequest req});
|
||||||
@@ -128,7 +128,7 @@ abstract class RustLibApi extends BaseApi {
|
|||||||
{required BindingLiquidSdk that, required PrepareReceiveOnchainResponse req});
|
{required BindingLiquidSdk that, required PrepareReceiveOnchainResponse req});
|
||||||
|
|
||||||
Future<ReceivePaymentResponse> crateBindingsBindingLiquidSdkReceivePayment(
|
Future<ReceivePaymentResponse> crateBindingsBindingLiquidSdkReceivePayment(
|
||||||
{required BindingLiquidSdk that, required PrepareReceiveResponse req});
|
{required BindingLiquidSdk that, required ReceivePaymentRequest req});
|
||||||
|
|
||||||
Future<RecommendedFees> crateBindingsBindingLiquidSdkRecommendedFees({required BindingLiquidSdk that});
|
Future<RecommendedFees> crateBindingsBindingLiquidSdkRecommendedFees({required BindingLiquidSdk that});
|
||||||
|
|
||||||
@@ -655,18 +655,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PrepareReceiveResponse> crateBindingsBindingLiquidSdkPrepareReceivePayment(
|
Future<PrepareReceivePaymentResponse> crateBindingsBindingLiquidSdkPrepareReceivePayment(
|
||||||
{required BindingLiquidSdk that, required PrepareReceiveRequest req}) {
|
{required BindingLiquidSdk that, required PrepareReceivePaymentRequest req}) {
|
||||||
return handler.executeNormal(NormalTask(
|
return handler.executeNormal(NormalTask(
|
||||||
callFfi: (port_) {
|
callFfi: (port_) {
|
||||||
var arg0 =
|
var arg0 =
|
||||||
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||||
that);
|
that);
|
||||||
var arg1 = cst_encode_box_autoadd_prepare_receive_request(req);
|
var arg1 = cst_encode_box_autoadd_prepare_receive_payment_request(req);
|
||||||
return wire.wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(port_, arg0, arg1);
|
return wire.wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(port_, arg0, arg1);
|
||||||
},
|
},
|
||||||
codec: DcoCodec(
|
codec: DcoCodec(
|
||||||
decodeSuccessData: dco_decode_prepare_receive_response,
|
decodeSuccessData: dco_decode_prepare_receive_payment_response,
|
||||||
decodeErrorData: dco_decode_payment_error,
|
decodeErrorData: dco_decode_payment_error,
|
||||||
),
|
),
|
||||||
constMeta: kCrateBindingsBindingLiquidSdkPrepareReceivePaymentConstMeta,
|
constMeta: kCrateBindingsBindingLiquidSdkPrepareReceivePaymentConstMeta,
|
||||||
@@ -760,13 +760,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ReceivePaymentResponse> crateBindingsBindingLiquidSdkReceivePayment(
|
Future<ReceivePaymentResponse> crateBindingsBindingLiquidSdkReceivePayment(
|
||||||
{required BindingLiquidSdk that, required PrepareReceiveResponse req}) {
|
{required BindingLiquidSdk that, required ReceivePaymentRequest req}) {
|
||||||
return handler.executeNormal(NormalTask(
|
return handler.executeNormal(NormalTask(
|
||||||
callFfi: (port_) {
|
callFfi: (port_) {
|
||||||
var arg0 =
|
var arg0 =
|
||||||
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||||
that);
|
that);
|
||||||
var arg1 = cst_encode_box_autoadd_prepare_receive_response(req);
|
var arg1 = cst_encode_box_autoadd_receive_payment_request(req);
|
||||||
return wire.wire__crate__bindings__BindingLiquidSdk_receive_payment(port_, arg0, arg1);
|
return wire.wire__crate__bindings__BindingLiquidSdk_receive_payment(port_, arg0, arg1);
|
||||||
},
|
},
|
||||||
codec: DcoCodec(
|
codec: DcoCodec(
|
||||||
@@ -1354,15 +1354,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest dco_decode_box_autoadd_prepare_receive_request(dynamic raw) {
|
PrepareReceivePaymentRequest dco_decode_box_autoadd_prepare_receive_payment_request(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
return dco_decode_prepare_receive_request(raw);
|
return dco_decode_prepare_receive_payment_request(raw);
|
||||||
}
|
|
||||||
|
|
||||||
@protected
|
|
||||||
PrepareReceiveResponse dco_decode_box_autoadd_prepare_receive_response(dynamic raw) {
|
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
|
||||||
return dco_decode_prepare_receive_response(raw);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
@@ -1383,6 +1377,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
return dco_decode_prepare_send_response(raw);
|
return dco_decode_prepare_send_response(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest dco_decode_box_autoadd_receive_payment_request(dynamic raw) {
|
||||||
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
|
return dco_decode_receive_payment_request(raw);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RefundRequest dco_decode_box_autoadd_refund_request(dynamic raw) {
|
RefundRequest dco_decode_box_autoadd_refund_request(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
@@ -2102,7 +2102,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
Payment dco_decode_payment(dynamic raw) {
|
Payment dco_decode_payment(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
final arr = raw as List<dynamic>;
|
final arr = raw as List<dynamic>;
|
||||||
if (arr.length != 11) throw Exception('unexpected arr length: expect 11 but see ${arr.length}');
|
if (arr.length != 12) throw Exception('unexpected arr length: expect 12 but see ${arr.length}');
|
||||||
return Payment(
|
return Payment(
|
||||||
txId: dco_decode_opt_String(arr[0]),
|
txId: dco_decode_opt_String(arr[0]),
|
||||||
swapId: dco_decode_opt_String(arr[1]),
|
swapId: dco_decode_opt_String(arr[1]),
|
||||||
@@ -2111,10 +2111,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
feesSat: dco_decode_u_64(arr[4]),
|
feesSat: dco_decode_u_64(arr[4]),
|
||||||
preimage: dco_decode_opt_String(arr[5]),
|
preimage: dco_decode_opt_String(arr[5]),
|
||||||
bolt11: dco_decode_opt_String(arr[6]),
|
bolt11: dco_decode_opt_String(arr[6]),
|
||||||
refundTxId: dco_decode_opt_String(arr[7]),
|
description: dco_decode_String(arr[7]),
|
||||||
refundTxAmountSat: dco_decode_opt_box_autoadd_u_64(arr[8]),
|
refundTxId: dco_decode_opt_String(arr[8]),
|
||||||
paymentType: dco_decode_payment_type(arr[9]),
|
refundTxAmountSat: dco_decode_opt_box_autoadd_u_64(arr[9]),
|
||||||
status: dco_decode_payment_state(arr[10]),
|
paymentType: dco_decode_payment_type(arr[10]),
|
||||||
|
status: dco_decode_payment_state(arr[11]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2258,21 +2259,21 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest dco_decode_prepare_receive_request(dynamic raw) {
|
PrepareReceivePaymentRequest dco_decode_prepare_receive_payment_request(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
final arr = raw as List<dynamic>;
|
final arr = raw as List<dynamic>;
|
||||||
if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}');
|
if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}');
|
||||||
return PrepareReceiveRequest(
|
return PrepareReceivePaymentRequest(
|
||||||
payerAmountSat: dco_decode_u_64(arr[0]),
|
payerAmountSat: dco_decode_u_64(arr[0]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveResponse dco_decode_prepare_receive_response(dynamic raw) {
|
PrepareReceivePaymentResponse dco_decode_prepare_receive_payment_response(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
final arr = raw as List<dynamic>;
|
final arr = raw as List<dynamic>;
|
||||||
if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
|
if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
|
||||||
return PrepareReceiveResponse(
|
return PrepareReceivePaymentResponse(
|
||||||
payerAmountSat: dco_decode_u_64(arr[0]),
|
payerAmountSat: dco_decode_u_64(arr[0]),
|
||||||
feesSat: dco_decode_u_64(arr[1]),
|
feesSat: dco_decode_u_64(arr[1]),
|
||||||
);
|
);
|
||||||
@@ -2345,6 +2346,17 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest dco_decode_receive_payment_request(dynamic raw) {
|
||||||
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
|
final arr = raw as List<dynamic>;
|
||||||
|
if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
|
||||||
|
return ReceivePaymentRequest(
|
||||||
|
description: dco_decode_opt_String(arr[0]),
|
||||||
|
prepareRes: dco_decode_prepare_receive_payment_response(arr[1]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ReceivePaymentResponse dco_decode_receive_payment_response(dynamic raw) {
|
ReceivePaymentResponse dco_decode_receive_payment_response(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
@@ -2868,15 +2880,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest sse_decode_box_autoadd_prepare_receive_request(SseDeserializer deserializer) {
|
PrepareReceivePaymentRequest sse_decode_box_autoadd_prepare_receive_payment_request(
|
||||||
|
SseDeserializer deserializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
return (sse_decode_prepare_receive_request(deserializer));
|
return (sse_decode_prepare_receive_payment_request(deserializer));
|
||||||
}
|
|
||||||
|
|
||||||
@protected
|
|
||||||
PrepareReceiveResponse sse_decode_box_autoadd_prepare_receive_response(SseDeserializer deserializer) {
|
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
|
||||||
return (sse_decode_prepare_receive_response(deserializer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
@@ -2897,6 +2904,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
return (sse_decode_prepare_send_response(deserializer));
|
return (sse_decode_prepare_send_response(deserializer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest sse_decode_box_autoadd_receive_payment_request(SseDeserializer deserializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
return (sse_decode_receive_payment_request(deserializer));
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RefundRequest sse_decode_box_autoadd_refund_request(SseDeserializer deserializer) {
|
RefundRequest sse_decode_box_autoadd_refund_request(SseDeserializer deserializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
@@ -3679,6 +3692,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
var var_feesSat = sse_decode_u_64(deserializer);
|
var var_feesSat = sse_decode_u_64(deserializer);
|
||||||
var var_preimage = sse_decode_opt_String(deserializer);
|
var var_preimage = sse_decode_opt_String(deserializer);
|
||||||
var var_bolt11 = sse_decode_opt_String(deserializer);
|
var var_bolt11 = sse_decode_opt_String(deserializer);
|
||||||
|
var var_description = sse_decode_String(deserializer);
|
||||||
var var_refundTxId = sse_decode_opt_String(deserializer);
|
var var_refundTxId = sse_decode_opt_String(deserializer);
|
||||||
var var_refundTxAmountSat = sse_decode_opt_box_autoadd_u_64(deserializer);
|
var var_refundTxAmountSat = sse_decode_opt_box_autoadd_u_64(deserializer);
|
||||||
var var_paymentType = sse_decode_payment_type(deserializer);
|
var var_paymentType = sse_decode_payment_type(deserializer);
|
||||||
@@ -3691,6 +3705,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
feesSat: var_feesSat,
|
feesSat: var_feesSat,
|
||||||
preimage: var_preimage,
|
preimage: var_preimage,
|
||||||
bolt11: var_bolt11,
|
bolt11: var_bolt11,
|
||||||
|
description: var_description,
|
||||||
refundTxId: var_refundTxId,
|
refundTxId: var_refundTxId,
|
||||||
refundTxAmountSat: var_refundTxAmountSat,
|
refundTxAmountSat: var_refundTxAmountSat,
|
||||||
paymentType: var_paymentType,
|
paymentType: var_paymentType,
|
||||||
@@ -3819,18 +3834,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest sse_decode_prepare_receive_request(SseDeserializer deserializer) {
|
PrepareReceivePaymentRequest sse_decode_prepare_receive_payment_request(SseDeserializer deserializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
var var_payerAmountSat = sse_decode_u_64(deserializer);
|
var var_payerAmountSat = sse_decode_u_64(deserializer);
|
||||||
return PrepareReceiveRequest(payerAmountSat: var_payerAmountSat);
|
return PrepareReceivePaymentRequest(payerAmountSat: var_payerAmountSat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveResponse sse_decode_prepare_receive_response(SseDeserializer deserializer) {
|
PrepareReceivePaymentResponse sse_decode_prepare_receive_payment_response(SseDeserializer deserializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
var var_payerAmountSat = sse_decode_u_64(deserializer);
|
var var_payerAmountSat = sse_decode_u_64(deserializer);
|
||||||
var var_feesSat = sse_decode_u_64(deserializer);
|
var var_feesSat = sse_decode_u_64(deserializer);
|
||||||
return PrepareReceiveResponse(payerAmountSat: var_payerAmountSat, feesSat: var_feesSat);
|
return PrepareReceivePaymentResponse(payerAmountSat: var_payerAmountSat, feesSat: var_feesSat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
@@ -3883,6 +3898,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
return ReceiveOnchainResponse(address: var_address, bip21: var_bip21);
|
return ReceiveOnchainResponse(address: var_address, bip21: var_bip21);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest sse_decode_receive_payment_request(SseDeserializer deserializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
var var_description = sse_decode_opt_String(deserializer);
|
||||||
|
var var_prepareRes = sse_decode_prepare_receive_payment_response(deserializer);
|
||||||
|
return ReceivePaymentRequest(description: var_description, prepareRes: var_prepareRes);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ReceivePaymentResponse sse_decode_receive_payment_response(SseDeserializer deserializer) {
|
ReceivePaymentResponse sse_decode_receive_payment_response(SseDeserializer deserializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
@@ -4477,16 +4500,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_prepare_receive_request(PrepareReceiveRequest self, SseSerializer serializer) {
|
void sse_encode_box_autoadd_prepare_receive_payment_request(
|
||||||
|
PrepareReceivePaymentRequest self, SseSerializer serializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
sse_encode_prepare_receive_request(self, serializer);
|
sse_encode_prepare_receive_payment_request(self, serializer);
|
||||||
}
|
|
||||||
|
|
||||||
@protected
|
|
||||||
void sse_encode_box_autoadd_prepare_receive_response(
|
|
||||||
PrepareReceiveResponse self, SseSerializer serializer) {
|
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
|
||||||
sse_encode_prepare_receive_response(self, serializer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
@@ -4507,6 +4524,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
sse_encode_prepare_send_response(self, serializer);
|
sse_encode_prepare_send_response(self, serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_box_autoadd_receive_payment_request(ReceivePaymentRequest self, SseSerializer serializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
sse_encode_receive_payment_request(self, serializer);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_refund_request(RefundRequest self, SseSerializer serializer) {
|
void sse_encode_box_autoadd_refund_request(RefundRequest self, SseSerializer serializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
@@ -5161,6 +5184,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
sse_encode_u_64(self.feesSat, serializer);
|
sse_encode_u_64(self.feesSat, serializer);
|
||||||
sse_encode_opt_String(self.preimage, serializer);
|
sse_encode_opt_String(self.preimage, serializer);
|
||||||
sse_encode_opt_String(self.bolt11, serializer);
|
sse_encode_opt_String(self.bolt11, serializer);
|
||||||
|
sse_encode_String(self.description, serializer);
|
||||||
sse_encode_opt_String(self.refundTxId, serializer);
|
sse_encode_opt_String(self.refundTxId, serializer);
|
||||||
sse_encode_opt_box_autoadd_u_64(self.refundTxAmountSat, serializer);
|
sse_encode_opt_box_autoadd_u_64(self.refundTxAmountSat, serializer);
|
||||||
sse_encode_payment_type(self.paymentType, serializer);
|
sse_encode_payment_type(self.paymentType, serializer);
|
||||||
@@ -5278,13 +5302,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_prepare_receive_request(PrepareReceiveRequest self, SseSerializer serializer) {
|
void sse_encode_prepare_receive_payment_request(
|
||||||
|
PrepareReceivePaymentRequest self, SseSerializer serializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
sse_encode_u_64(self.payerAmountSat, serializer);
|
sse_encode_u_64(self.payerAmountSat, serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_prepare_receive_response(PrepareReceiveResponse self, SseSerializer serializer) {
|
void sse_encode_prepare_receive_payment_response(
|
||||||
|
PrepareReceivePaymentResponse self, SseSerializer serializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
sse_encode_u_64(self.payerAmountSat, serializer);
|
sse_encode_u_64(self.payerAmountSat, serializer);
|
||||||
sse_encode_u_64(self.feesSat, serializer);
|
sse_encode_u_64(self.feesSat, serializer);
|
||||||
@@ -5333,6 +5359,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
sse_encode_String(self.bip21, serializer);
|
sse_encode_String(self.bip21, serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_receive_payment_request(ReceivePaymentRequest self, SseSerializer serializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
sse_encode_opt_String(self.description, serializer);
|
||||||
|
sse_encode_prepare_receive_payment_response(self.prepareRes, serializer);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_receive_payment_response(ReceivePaymentResponse self, SseSerializer serializer) {
|
void sse_encode_receive_payment_response(ReceivePaymentResponse self, SseSerializer serializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
@@ -5607,7 +5640,7 @@ class BindingLiquidSdkImpl extends RustOpaque implements BindingLiquidSdk {
|
|||||||
Future<PrepareReceiveOnchainResponse> prepareReceiveOnchain({required PrepareReceiveOnchainRequest req}) =>
|
Future<PrepareReceiveOnchainResponse> prepareReceiveOnchain({required PrepareReceiveOnchainRequest req}) =>
|
||||||
RustLib.instance.api.crateBindingsBindingLiquidSdkPrepareReceiveOnchain(that: this, req: req);
|
RustLib.instance.api.crateBindingsBindingLiquidSdkPrepareReceiveOnchain(that: this, req: req);
|
||||||
|
|
||||||
Future<PrepareReceiveResponse> prepareReceivePayment({required PrepareReceiveRequest req}) =>
|
Future<PrepareReceivePaymentResponse> prepareReceivePayment({required PrepareReceivePaymentRequest req}) =>
|
||||||
RustLib.instance.api.crateBindingsBindingLiquidSdkPrepareReceivePayment(that: this, req: req);
|
RustLib.instance.api.crateBindingsBindingLiquidSdkPrepareReceivePayment(that: this, req: req);
|
||||||
|
|
||||||
Future<PrepareRefundResponse> prepareRefund({required PrepareRefundRequest req}) =>
|
Future<PrepareRefundResponse> prepareRefund({required PrepareRefundRequest req}) =>
|
||||||
@@ -5619,7 +5652,7 @@ class BindingLiquidSdkImpl extends RustOpaque implements BindingLiquidSdk {
|
|||||||
Future<ReceiveOnchainResponse> receiveOnchain({required PrepareReceiveOnchainResponse req}) =>
|
Future<ReceiveOnchainResponse> receiveOnchain({required PrepareReceiveOnchainResponse req}) =>
|
||||||
RustLib.instance.api.crateBindingsBindingLiquidSdkReceiveOnchain(that: this, req: req);
|
RustLib.instance.api.crateBindingsBindingLiquidSdkReceiveOnchain(that: this, req: req);
|
||||||
|
|
||||||
Future<ReceivePaymentResponse> receivePayment({required PrepareReceiveResponse req}) =>
|
Future<ReceivePaymentResponse> receivePayment({required ReceivePaymentRequest req}) =>
|
||||||
RustLib.instance.api.crateBindingsBindingLiquidSdkReceivePayment(that: this, req: req);
|
RustLib.instance.api.crateBindingsBindingLiquidSdkReceivePayment(that: this, req: req);
|
||||||
|
|
||||||
Future<RecommendedFees> recommendedFees() =>
|
Future<RecommendedFees> recommendedFees() =>
|
||||||
|
|||||||
@@ -150,10 +150,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
PrepareReceiveOnchainResponse dco_decode_box_autoadd_prepare_receive_onchain_response(dynamic raw);
|
PrepareReceiveOnchainResponse dco_decode_box_autoadd_prepare_receive_onchain_response(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest dco_decode_box_autoadd_prepare_receive_request(dynamic raw);
|
PrepareReceivePaymentRequest dco_decode_box_autoadd_prepare_receive_payment_request(dynamic raw);
|
||||||
|
|
||||||
@protected
|
|
||||||
PrepareReceiveResponse dco_decode_box_autoadd_prepare_receive_response(dynamic raw);
|
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareRefundRequest dco_decode_box_autoadd_prepare_refund_request(dynamic raw);
|
PrepareRefundRequest dco_decode_box_autoadd_prepare_refund_request(dynamic raw);
|
||||||
@@ -164,6 +161,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
PrepareSendResponse dco_decode_box_autoadd_prepare_send_response(dynamic raw);
|
PrepareSendResponse dco_decode_box_autoadd_prepare_send_response(dynamic raw);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest dco_decode_box_autoadd_receive_payment_request(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RefundRequest dco_decode_box_autoadd_refund_request(dynamic raw);
|
RefundRequest dco_decode_box_autoadd_refund_request(dynamic raw);
|
||||||
|
|
||||||
@@ -387,10 +387,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
PrepareReceiveOnchainResponse dco_decode_prepare_receive_onchain_response(dynamic raw);
|
PrepareReceiveOnchainResponse dco_decode_prepare_receive_onchain_response(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest dco_decode_prepare_receive_request(dynamic raw);
|
PrepareReceivePaymentRequest dco_decode_prepare_receive_payment_request(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveResponse dco_decode_prepare_receive_response(dynamic raw);
|
PrepareReceivePaymentResponse dco_decode_prepare_receive_payment_response(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareRefundRequest dco_decode_prepare_refund_request(dynamic raw);
|
PrepareRefundRequest dco_decode_prepare_refund_request(dynamic raw);
|
||||||
@@ -410,6 +410,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
ReceiveOnchainResponse dco_decode_receive_onchain_response(dynamic raw);
|
ReceiveOnchainResponse dco_decode_receive_onchain_response(dynamic raw);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest dco_decode_receive_payment_request(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ReceivePaymentResponse dco_decode_receive_payment_response(dynamic raw);
|
ReceivePaymentResponse dco_decode_receive_payment_response(dynamic raw);
|
||||||
|
|
||||||
@@ -600,10 +603,8 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
SseDeserializer deserializer);
|
SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest sse_decode_box_autoadd_prepare_receive_request(SseDeserializer deserializer);
|
PrepareReceivePaymentRequest sse_decode_box_autoadd_prepare_receive_payment_request(
|
||||||
|
SseDeserializer deserializer);
|
||||||
@protected
|
|
||||||
PrepareReceiveResponse sse_decode_box_autoadd_prepare_receive_response(SseDeserializer deserializer);
|
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareRefundRequest sse_decode_box_autoadd_prepare_refund_request(SseDeserializer deserializer);
|
PrepareRefundRequest sse_decode_box_autoadd_prepare_refund_request(SseDeserializer deserializer);
|
||||||
@@ -614,6 +615,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
PrepareSendResponse sse_decode_box_autoadd_prepare_send_response(SseDeserializer deserializer);
|
PrepareSendResponse sse_decode_box_autoadd_prepare_send_response(SseDeserializer deserializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest sse_decode_box_autoadd_receive_payment_request(SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RefundRequest sse_decode_box_autoadd_refund_request(SseDeserializer deserializer);
|
RefundRequest sse_decode_box_autoadd_refund_request(SseDeserializer deserializer);
|
||||||
|
|
||||||
@@ -837,10 +841,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
PrepareReceiveOnchainResponse sse_decode_prepare_receive_onchain_response(SseDeserializer deserializer);
|
PrepareReceiveOnchainResponse sse_decode_prepare_receive_onchain_response(SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveRequest sse_decode_prepare_receive_request(SseDeserializer deserializer);
|
PrepareReceivePaymentRequest sse_decode_prepare_receive_payment_request(SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareReceiveResponse sse_decode_prepare_receive_response(SseDeserializer deserializer);
|
PrepareReceivePaymentResponse sse_decode_prepare_receive_payment_response(SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
PrepareRefundRequest sse_decode_prepare_refund_request(SseDeserializer deserializer);
|
PrepareRefundRequest sse_decode_prepare_refund_request(SseDeserializer deserializer);
|
||||||
@@ -860,6 +864,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
ReceiveOnchainResponse sse_decode_receive_onchain_response(SseDeserializer deserializer);
|
ReceiveOnchainResponse sse_decode_receive_onchain_response(SseDeserializer deserializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ReceivePaymentRequest sse_decode_receive_payment_request(SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ReceivePaymentResponse sse_decode_receive_payment_response(SseDeserializer deserializer);
|
ReceivePaymentResponse sse_decode_receive_payment_response(SseDeserializer deserializer);
|
||||||
|
|
||||||
@@ -1186,20 +1193,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ffi.Pointer<wire_cst_prepare_receive_request> cst_encode_box_autoadd_prepare_receive_request(
|
ffi.Pointer<wire_cst_prepare_receive_payment_request>
|
||||||
PrepareReceiveRequest raw) {
|
cst_encode_box_autoadd_prepare_receive_payment_request(PrepareReceivePaymentRequest raw) {
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
final ptr = wire.cst_new_box_autoadd_prepare_receive_request();
|
final ptr = wire.cst_new_box_autoadd_prepare_receive_payment_request();
|
||||||
cst_api_fill_to_wire_prepare_receive_request(raw, ptr.ref);
|
cst_api_fill_to_wire_prepare_receive_payment_request(raw, ptr.ref);
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@protected
|
|
||||||
ffi.Pointer<wire_cst_prepare_receive_response> cst_encode_box_autoadd_prepare_receive_response(
|
|
||||||
PrepareReceiveResponse raw) {
|
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
|
||||||
final ptr = wire.cst_new_box_autoadd_prepare_receive_response();
|
|
||||||
cst_api_fill_to_wire_prepare_receive_response(raw, ptr.ref);
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1230,6 +1228,15 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ffi.Pointer<wire_cst_receive_payment_request> cst_encode_box_autoadd_receive_payment_request(
|
||||||
|
ReceivePaymentRequest raw) {
|
||||||
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
|
final ptr = wire.cst_new_box_autoadd_receive_payment_request();
|
||||||
|
cst_api_fill_to_wire_receive_payment_request(raw, ptr.ref);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ffi.Pointer<wire_cst_refund_request> cst_encode_box_autoadd_refund_request(RefundRequest raw) {
|
ffi.Pointer<wire_cst_refund_request> cst_encode_box_autoadd_refund_request(RefundRequest raw) {
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
@@ -1652,15 +1659,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void cst_api_fill_to_wire_box_autoadd_prepare_receive_request(
|
void cst_api_fill_to_wire_box_autoadd_prepare_receive_payment_request(
|
||||||
PrepareReceiveRequest apiObj, ffi.Pointer<wire_cst_prepare_receive_request> wireObj) {
|
PrepareReceivePaymentRequest apiObj, ffi.Pointer<wire_cst_prepare_receive_payment_request> wireObj) {
|
||||||
cst_api_fill_to_wire_prepare_receive_request(apiObj, wireObj.ref);
|
cst_api_fill_to_wire_prepare_receive_payment_request(apiObj, wireObj.ref);
|
||||||
}
|
|
||||||
|
|
||||||
@protected
|
|
||||||
void cst_api_fill_to_wire_box_autoadd_prepare_receive_response(
|
|
||||||
PrepareReceiveResponse apiObj, ffi.Pointer<wire_cst_prepare_receive_response> wireObj) {
|
|
||||||
cst_api_fill_to_wire_prepare_receive_response(apiObj, wireObj.ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
@@ -1681,6 +1682,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
cst_api_fill_to_wire_prepare_send_response(apiObj, wireObj.ref);
|
cst_api_fill_to_wire_prepare_send_response(apiObj, wireObj.ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void cst_api_fill_to_wire_box_autoadd_receive_payment_request(
|
||||||
|
ReceivePaymentRequest apiObj, ffi.Pointer<wire_cst_receive_payment_request> wireObj) {
|
||||||
|
cst_api_fill_to_wire_receive_payment_request(apiObj, wireObj.ref);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void cst_api_fill_to_wire_box_autoadd_refund_request(
|
void cst_api_fill_to_wire_box_autoadd_refund_request(
|
||||||
RefundRequest apiObj, ffi.Pointer<wire_cst_refund_request> wireObj) {
|
RefundRequest apiObj, ffi.Pointer<wire_cst_refund_request> wireObj) {
|
||||||
@@ -2177,6 +2184,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat);
|
wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat);
|
||||||
wireObj.preimage = cst_encode_opt_String(apiObj.preimage);
|
wireObj.preimage = cst_encode_opt_String(apiObj.preimage);
|
||||||
wireObj.bolt11 = cst_encode_opt_String(apiObj.bolt11);
|
wireObj.bolt11 = cst_encode_opt_String(apiObj.bolt11);
|
||||||
|
wireObj.description = cst_encode_String(apiObj.description);
|
||||||
wireObj.refund_tx_id = cst_encode_opt_String(apiObj.refundTxId);
|
wireObj.refund_tx_id = cst_encode_opt_String(apiObj.refundTxId);
|
||||||
wireObj.refund_tx_amount_sat = cst_encode_opt_box_autoadd_u_64(apiObj.refundTxAmountSat);
|
wireObj.refund_tx_amount_sat = cst_encode_opt_box_autoadd_u_64(apiObj.refundTxAmountSat);
|
||||||
wireObj.payment_type = cst_encode_payment_type(apiObj.paymentType);
|
wireObj.payment_type = cst_encode_payment_type(apiObj.paymentType);
|
||||||
@@ -2319,14 +2327,14 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void cst_api_fill_to_wire_prepare_receive_request(
|
void cst_api_fill_to_wire_prepare_receive_payment_request(
|
||||||
PrepareReceiveRequest apiObj, wire_cst_prepare_receive_request wireObj) {
|
PrepareReceivePaymentRequest apiObj, wire_cst_prepare_receive_payment_request wireObj) {
|
||||||
wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat);
|
wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void cst_api_fill_to_wire_prepare_receive_response(
|
void cst_api_fill_to_wire_prepare_receive_payment_response(
|
||||||
PrepareReceiveResponse apiObj, wire_cst_prepare_receive_response wireObj) {
|
PrepareReceivePaymentResponse apiObj, wire_cst_prepare_receive_payment_response wireObj) {
|
||||||
wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat);
|
wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat);
|
||||||
wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat);
|
wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat);
|
||||||
}
|
}
|
||||||
@@ -2373,6 +2381,13 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
wireObj.bip21 = cst_encode_String(apiObj.bip21);
|
wireObj.bip21 = cst_encode_String(apiObj.bip21);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void cst_api_fill_to_wire_receive_payment_request(
|
||||||
|
ReceivePaymentRequest apiObj, wire_cst_receive_payment_request wireObj) {
|
||||||
|
wireObj.description = cst_encode_opt_String(apiObj.description);
|
||||||
|
cst_api_fill_to_wire_prepare_receive_payment_response(apiObj.prepareRes, wireObj.prepare_res);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void cst_api_fill_to_wire_receive_payment_response(
|
void cst_api_fill_to_wire_receive_payment_response(
|
||||||
ReceivePaymentResponse apiObj, wire_cst_receive_payment_response wireObj) {
|
ReceivePaymentResponse apiObj, wire_cst_receive_payment_response wireObj) {
|
||||||
@@ -2724,10 +2739,8 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
PrepareReceiveOnchainResponse self, SseSerializer serializer);
|
PrepareReceiveOnchainResponse self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_prepare_receive_request(PrepareReceiveRequest self, SseSerializer serializer);
|
void sse_encode_box_autoadd_prepare_receive_payment_request(
|
||||||
|
PrepareReceivePaymentRequest self, SseSerializer serializer);
|
||||||
@protected
|
|
||||||
void sse_encode_box_autoadd_prepare_receive_response(PrepareReceiveResponse self, SseSerializer serializer);
|
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_prepare_refund_request(PrepareRefundRequest self, SseSerializer serializer);
|
void sse_encode_box_autoadd_prepare_refund_request(PrepareRefundRequest self, SseSerializer serializer);
|
||||||
@@ -2738,6 +2751,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_prepare_send_response(PrepareSendResponse self, SseSerializer serializer);
|
void sse_encode_box_autoadd_prepare_send_response(PrepareSendResponse self, SseSerializer serializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_box_autoadd_receive_payment_request(ReceivePaymentRequest self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_refund_request(RefundRequest self, SseSerializer serializer);
|
void sse_encode_box_autoadd_refund_request(RefundRequest self, SseSerializer serializer);
|
||||||
|
|
||||||
@@ -2966,10 +2982,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
PrepareReceiveOnchainResponse self, SseSerializer serializer);
|
PrepareReceiveOnchainResponse self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_prepare_receive_request(PrepareReceiveRequest self, SseSerializer serializer);
|
void sse_encode_prepare_receive_payment_request(
|
||||||
|
PrepareReceivePaymentRequest self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_prepare_receive_response(PrepareReceiveResponse self, SseSerializer serializer);
|
void sse_encode_prepare_receive_payment_response(
|
||||||
|
PrepareReceivePaymentResponse self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_prepare_refund_request(PrepareRefundRequest self, SseSerializer serializer);
|
void sse_encode_prepare_refund_request(PrepareRefundRequest self, SseSerializer serializer);
|
||||||
@@ -2989,6 +3007,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
void sse_encode_receive_onchain_response(ReceiveOnchainResponse self, SseSerializer serializer);
|
void sse_encode_receive_onchain_response(ReceiveOnchainResponse self, SseSerializer serializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_receive_payment_request(ReceivePaymentRequest self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_receive_payment_response(ReceivePaymentResponse self, SseSerializer serializer);
|
void sse_encode_receive_payment_response(ReceivePaymentResponse self, SseSerializer serializer);
|
||||||
|
|
||||||
@@ -3435,7 +3456,7 @@ class RustLibWire implements BaseWire {
|
|||||||
void wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
void wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
||||||
int port_,
|
int port_,
|
||||||
int that,
|
int that,
|
||||||
ffi.Pointer<wire_cst_prepare_receive_request> req,
|
ffi.Pointer<wire_cst_prepare_receive_payment_request> req,
|
||||||
) {
|
) {
|
||||||
return _wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
return _wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
||||||
port_,
|
port_,
|
||||||
@@ -3446,11 +3467,12 @@ class RustLibWire implements BaseWire {
|
|||||||
|
|
||||||
late final _wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr = _lookup<
|
late final _wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_prepare_receive_request>)>>(
|
ffi.Void Function(
|
||||||
|
ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_prepare_receive_payment_request>)>>(
|
||||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment');
|
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment');
|
||||||
late final _wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment =
|
late final _wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment =
|
||||||
_wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr
|
_wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr
|
||||||
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_prepare_receive_request>)>();
|
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_prepare_receive_payment_request>)>();
|
||||||
|
|
||||||
void wire__crate__bindings__BindingLiquidSdk_prepare_refund(
|
void wire__crate__bindings__BindingLiquidSdk_prepare_refund(
|
||||||
int port_,
|
int port_,
|
||||||
@@ -3516,7 +3538,7 @@ class RustLibWire implements BaseWire {
|
|||||||
void wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
void wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
||||||
int port_,
|
int port_,
|
||||||
int that,
|
int that,
|
||||||
ffi.Pointer<wire_cst_prepare_receive_response> req,
|
ffi.Pointer<wire_cst_receive_payment_request> req,
|
||||||
) {
|
) {
|
||||||
return _wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
return _wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
||||||
port_,
|
port_,
|
||||||
@@ -3527,11 +3549,11 @@ class RustLibWire implements BaseWire {
|
|||||||
|
|
||||||
late final _wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr = _lookup<
|
late final _wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_prepare_receive_response>)>>(
|
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_receive_payment_request>)>>(
|
||||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment');
|
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment');
|
||||||
late final _wire__crate__bindings__BindingLiquidSdk_receive_payment =
|
late final _wire__crate__bindings__BindingLiquidSdk_receive_payment =
|
||||||
_wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr
|
_wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr
|
||||||
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_prepare_receive_response>)>();
|
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_receive_payment_request>)>();
|
||||||
|
|
||||||
void wire__crate__bindings__BindingLiquidSdk_recommended_fees(
|
void wire__crate__bindings__BindingLiquidSdk_recommended_fees(
|
||||||
int port_,
|
int port_,
|
||||||
@@ -4059,25 +4081,17 @@ class RustLibWire implements BaseWire {
|
|||||||
_cst_new_box_autoadd_prepare_receive_onchain_responsePtr
|
_cst_new_box_autoadd_prepare_receive_onchain_responsePtr
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_receive_onchain_response> Function()>();
|
.asFunction<ffi.Pointer<wire_cst_prepare_receive_onchain_response> Function()>();
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_prepare_receive_request> cst_new_box_autoadd_prepare_receive_request() {
|
ffi.Pointer<wire_cst_prepare_receive_payment_request>
|
||||||
return _cst_new_box_autoadd_prepare_receive_request();
|
cst_new_box_autoadd_prepare_receive_payment_request() {
|
||||||
|
return _cst_new_box_autoadd_prepare_receive_payment_request();
|
||||||
}
|
}
|
||||||
|
|
||||||
late final _cst_new_box_autoadd_prepare_receive_requestPtr =
|
late final _cst_new_box_autoadd_prepare_receive_payment_requestPtr =
|
||||||
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_prepare_receive_request> Function()>>(
|
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_prepare_receive_payment_request> Function()>>(
|
||||||
'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request');
|
'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request');
|
||||||
late final _cst_new_box_autoadd_prepare_receive_request = _cst_new_box_autoadd_prepare_receive_requestPtr
|
late final _cst_new_box_autoadd_prepare_receive_payment_request =
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_receive_request> Function()>();
|
_cst_new_box_autoadd_prepare_receive_payment_requestPtr
|
||||||
|
.asFunction<ffi.Pointer<wire_cst_prepare_receive_payment_request> Function()>();
|
||||||
ffi.Pointer<wire_cst_prepare_receive_response> cst_new_box_autoadd_prepare_receive_response() {
|
|
||||||
return _cst_new_box_autoadd_prepare_receive_response();
|
|
||||||
}
|
|
||||||
|
|
||||||
late final _cst_new_box_autoadd_prepare_receive_responsePtr =
|
|
||||||
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_prepare_receive_response> Function()>>(
|
|
||||||
'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response');
|
|
||||||
late final _cst_new_box_autoadd_prepare_receive_response = _cst_new_box_autoadd_prepare_receive_responsePtr
|
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_receive_response> Function()>();
|
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_prepare_refund_request> cst_new_box_autoadd_prepare_refund_request() {
|
ffi.Pointer<wire_cst_prepare_refund_request> cst_new_box_autoadd_prepare_refund_request() {
|
||||||
return _cst_new_box_autoadd_prepare_refund_request();
|
return _cst_new_box_autoadd_prepare_refund_request();
|
||||||
@@ -4109,6 +4123,16 @@ class RustLibWire implements BaseWire {
|
|||||||
late final _cst_new_box_autoadd_prepare_send_response = _cst_new_box_autoadd_prepare_send_responsePtr
|
late final _cst_new_box_autoadd_prepare_send_response = _cst_new_box_autoadd_prepare_send_responsePtr
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_send_response> Function()>();
|
.asFunction<ffi.Pointer<wire_cst_prepare_send_response> Function()>();
|
||||||
|
|
||||||
|
ffi.Pointer<wire_cst_receive_payment_request> cst_new_box_autoadd_receive_payment_request() {
|
||||||
|
return _cst_new_box_autoadd_receive_payment_request();
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _cst_new_box_autoadd_receive_payment_requestPtr =
|
||||||
|
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_receive_payment_request> Function()>>(
|
||||||
|
'frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request');
|
||||||
|
late final _cst_new_box_autoadd_receive_payment_request = _cst_new_box_autoadd_receive_payment_requestPtr
|
||||||
|
.asFunction<ffi.Pointer<wire_cst_receive_payment_request> Function()>();
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_refund_request> cst_new_box_autoadd_refund_request() {
|
ffi.Pointer<wire_cst_refund_request> cst_new_box_autoadd_refund_request() {
|
||||||
return _cst_new_box_autoadd_refund_request();
|
return _cst_new_box_autoadd_refund_request();
|
||||||
}
|
}
|
||||||
@@ -4508,7 +4532,7 @@ final class wire_cst_prepare_receive_onchain_request extends ffi.Struct {
|
|||||||
external int payer_amount_sat;
|
external int payer_amount_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
final class wire_cst_prepare_receive_request extends ffi.Struct {
|
final class wire_cst_prepare_receive_payment_request extends ffi.Struct {
|
||||||
@ffi.Uint64()
|
@ffi.Uint64()
|
||||||
external int payer_amount_sat;
|
external int payer_amount_sat;
|
||||||
}
|
}
|
||||||
@@ -4534,7 +4558,7 @@ final class wire_cst_prepare_receive_onchain_response extends ffi.Struct {
|
|||||||
external int fees_sat;
|
external int fees_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
final class wire_cst_prepare_receive_response extends ffi.Struct {
|
final class wire_cst_prepare_receive_payment_response extends ffi.Struct {
|
||||||
@ffi.Uint64()
|
@ffi.Uint64()
|
||||||
external int payer_amount_sat;
|
external int payer_amount_sat;
|
||||||
|
|
||||||
@@ -4542,6 +4566,12 @@ final class wire_cst_prepare_receive_response extends ffi.Struct {
|
|||||||
external int fees_sat;
|
external int fees_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final class wire_cst_receive_payment_request extends ffi.Struct {
|
||||||
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> description;
|
||||||
|
|
||||||
|
external wire_cst_prepare_receive_payment_response prepare_res;
|
||||||
|
}
|
||||||
|
|
||||||
final class wire_cst_refund_request extends ffi.Struct {
|
final class wire_cst_refund_request extends ffi.Struct {
|
||||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> swap_address;
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> swap_address;
|
||||||
|
|
||||||
@@ -4584,6 +4614,8 @@ final class wire_cst_payment extends ffi.Struct {
|
|||||||
|
|
||||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> bolt11;
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> bolt11;
|
||||||
|
|
||||||
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> description;
|
||||||
|
|
||||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> refund_tx_id;
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> refund_tx_id;
|
||||||
|
|
||||||
external ffi.Pointer<ffi.Uint64> refund_tx_amount_sat;
|
external ffi.Pointer<ffi.Uint64> refund_tx_amount_sat;
|
||||||
|
|||||||
@@ -422,6 +422,9 @@ class Payment {
|
|||||||
/// In the case of a Receive payment, this is the invoice paid by the user
|
/// In the case of a Receive payment, this is the invoice paid by the user
|
||||||
final String? bolt11;
|
final String? bolt11;
|
||||||
|
|
||||||
|
/// Represents the invoice description
|
||||||
|
final String description;
|
||||||
|
|
||||||
/// For a Send swap which was refunded, this is the refund tx id
|
/// For a Send swap which was refunded, this is the refund tx id
|
||||||
final String? refundTxId;
|
final String? refundTxId;
|
||||||
|
|
||||||
@@ -446,6 +449,7 @@ class Payment {
|
|||||||
required this.feesSat,
|
required this.feesSat,
|
||||||
this.preimage,
|
this.preimage,
|
||||||
this.bolt11,
|
this.bolt11,
|
||||||
|
required this.description,
|
||||||
this.refundTxId,
|
this.refundTxId,
|
||||||
this.refundTxAmountSat,
|
this.refundTxAmountSat,
|
||||||
required this.paymentType,
|
required this.paymentType,
|
||||||
@@ -461,6 +465,7 @@ class Payment {
|
|||||||
feesSat.hashCode ^
|
feesSat.hashCode ^
|
||||||
preimage.hashCode ^
|
preimage.hashCode ^
|
||||||
bolt11.hashCode ^
|
bolt11.hashCode ^
|
||||||
|
description.hashCode ^
|
||||||
refundTxId.hashCode ^
|
refundTxId.hashCode ^
|
||||||
refundTxAmountSat.hashCode ^
|
refundTxAmountSat.hashCode ^
|
||||||
paymentType.hashCode ^
|
paymentType.hashCode ^
|
||||||
@@ -478,6 +483,7 @@ class Payment {
|
|||||||
feesSat == other.feesSat &&
|
feesSat == other.feesSat &&
|
||||||
preimage == other.preimage &&
|
preimage == other.preimage &&
|
||||||
bolt11 == other.bolt11 &&
|
bolt11 == other.bolt11 &&
|
||||||
|
description == other.description &&
|
||||||
refundTxId == other.refundTxId &&
|
refundTxId == other.refundTxId &&
|
||||||
refundTxAmountSat == other.refundTxAmountSat &&
|
refundTxAmountSat == other.refundTxAmountSat &&
|
||||||
paymentType == other.paymentType &&
|
paymentType == other.paymentType &&
|
||||||
@@ -694,10 +700,10 @@ class PrepareReceiveOnchainResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An argument when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
/// An argument when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
||||||
class PrepareReceiveRequest {
|
class PrepareReceivePaymentRequest {
|
||||||
final BigInt payerAmountSat;
|
final BigInt payerAmountSat;
|
||||||
|
|
||||||
const PrepareReceiveRequest({
|
const PrepareReceivePaymentRequest({
|
||||||
required this.payerAmountSat,
|
required this.payerAmountSat,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -707,17 +713,17 @@ class PrepareReceiveRequest {
|
|||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
other is PrepareReceiveRequest &&
|
other is PrepareReceivePaymentRequest &&
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
payerAmountSat == other.payerAmountSat;
|
payerAmountSat == other.payerAmountSat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returned when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
/// Returned when calling [crate::sdk::LiquidSdk::prepare_receive_payment].
|
||||||
class PrepareReceiveResponse {
|
class PrepareReceivePaymentResponse {
|
||||||
final BigInt payerAmountSat;
|
final BigInt payerAmountSat;
|
||||||
final BigInt feesSat;
|
final BigInt feesSat;
|
||||||
|
|
||||||
const PrepareReceiveResponse({
|
const PrepareReceivePaymentResponse({
|
||||||
required this.payerAmountSat,
|
required this.payerAmountSat,
|
||||||
required this.feesSat,
|
required this.feesSat,
|
||||||
});
|
});
|
||||||
@@ -728,7 +734,7 @@ class PrepareReceiveResponse {
|
|||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
other is PrepareReceiveResponse &&
|
other is PrepareReceivePaymentResponse &&
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
payerAmountSat == other.payerAmountSat &&
|
payerAmountSat == other.payerAmountSat &&
|
||||||
feesSat == other.feesSat;
|
feesSat == other.feesSat;
|
||||||
@@ -850,6 +856,28 @@ class ReceiveOnchainResponse {
|
|||||||
bip21 == other.bip21;
|
bip21 == other.bip21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An argument when calling [crate::sdk::LiquidSdk::receive_payment].
|
||||||
|
class ReceivePaymentRequest {
|
||||||
|
final String? description;
|
||||||
|
final PrepareReceivePaymentResponse prepareRes;
|
||||||
|
|
||||||
|
const ReceivePaymentRequest({
|
||||||
|
this.description,
|
||||||
|
required this.prepareRes,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => description.hashCode ^ prepareRes.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is ReceivePaymentRequest &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
description == other.description &&
|
||||||
|
prepareRes == other.prepareRes;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returned when calling [crate::sdk::LiquidSdk::receive_payment].
|
/// Returned when calling [crate::sdk::LiquidSdk::receive_payment].
|
||||||
class ReceivePaymentResponse {
|
class ReceivePaymentResponse {
|
||||||
final String id;
|
final String id;
|
||||||
|
|||||||
@@ -134,16 +134,17 @@ class _ReceivePaymentDialogState extends State<ReceivePaymentDialog> {
|
|||||||
try {
|
try {
|
||||||
setState(() => creatingInvoice = true);
|
setState(() => creatingInvoice = true);
|
||||||
int amountSat = int.parse(payerAmountController.text);
|
int amountSat = int.parse(payerAmountController.text);
|
||||||
PrepareReceiveRequest prepareReceiveReq =
|
PrepareReceivePaymentRequest prepareReceiveReq =
|
||||||
PrepareReceiveRequest(payerAmountSat: BigInt.from(amountSat));
|
PrepareReceivePaymentRequest(payerAmountSat: BigInt.from(amountSat));
|
||||||
PrepareReceiveResponse req = await widget.liquidSDK.prepareReceivePayment(
|
PrepareReceivePaymentResponse prepareRes = await widget.liquidSDK.prepareReceivePayment(
|
||||||
req: prepareReceiveReq,
|
req: prepareReceiveReq,
|
||||||
);
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
payerAmountSat = req.payerAmountSat.toInt();
|
payerAmountSat = prepareRes.payerAmountSat.toInt();
|
||||||
feesSat = req.feesSat.toInt();
|
feesSat = prepareRes.feesSat.toInt();
|
||||||
});
|
});
|
||||||
ReceivePaymentResponse resp = await widget.liquidSDK.receivePayment(req: req);
|
ReceivePaymentRequest receiveReq = ReceivePaymentRequest(prepareRes: prepareRes);
|
||||||
|
ReceivePaymentResponse resp = await widget.liquidSDK.receivePayment(req: receiveReq);
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"Created Invoice for $payerAmountSat sats with $feesSat sats fees.\nInvoice:${resp.invoice}",
|
"Created Invoice for $payerAmountSat sats with $feesSat sats fees.\nInvoice:${resp.invoice}",
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ class FlutterBreezLiquidBindings {
|
|||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
||||||
int port_,
|
int port_,
|
||||||
int that,
|
int that,
|
||||||
ffi.Pointer<wire_cst_prepare_receive_request> req,
|
ffi.Pointer<wire_cst_prepare_receive_payment_request> req,
|
||||||
) {
|
) {
|
||||||
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment(
|
||||||
port_,
|
port_,
|
||||||
@@ -406,11 +406,12 @@ class FlutterBreezLiquidBindings {
|
|||||||
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr =
|
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr =
|
||||||
_lookup<
|
_lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_prepare_receive_request>)>>(
|
ffi.Void Function(
|
||||||
|
ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_prepare_receive_payment_request>)>>(
|
||||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment');
|
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment');
|
||||||
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment =
|
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_payment =
|
||||||
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr
|
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_receive_paymentPtr
|
||||||
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_prepare_receive_request>)>();
|
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_prepare_receive_payment_request>)>();
|
||||||
|
|
||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_refund(
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_prepare_refund(
|
||||||
int port_,
|
int port_,
|
||||||
@@ -476,7 +477,7 @@ class FlutterBreezLiquidBindings {
|
|||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
||||||
int port_,
|
int port_,
|
||||||
int that,
|
int that,
|
||||||
ffi.Pointer<wire_cst_prepare_receive_response> req,
|
ffi.Pointer<wire_cst_receive_payment_request> req,
|
||||||
) {
|
) {
|
||||||
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment(
|
||||||
port_,
|
port_,
|
||||||
@@ -487,11 +488,11 @@ class FlutterBreezLiquidBindings {
|
|||||||
|
|
||||||
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr = _lookup<
|
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_prepare_receive_response>)>>(
|
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_receive_payment_request>)>>(
|
||||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment');
|
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment');
|
||||||
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment =
|
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_payment =
|
||||||
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr
|
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_receive_paymentPtr
|
||||||
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_prepare_receive_response>)>();
|
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_receive_payment_request>)>();
|
||||||
|
|
||||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_recommended_fees(
|
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_recommended_fees(
|
||||||
int port_,
|
int port_,
|
||||||
@@ -1056,29 +1057,17 @@ class FlutterBreezLiquidBindings {
|
|||||||
_frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_responsePtr
|
_frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_onchain_responsePtr
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_receive_onchain_response> Function()>();
|
.asFunction<ffi.Pointer<wire_cst_prepare_receive_onchain_response> Function()>();
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_prepare_receive_request>
|
ffi.Pointer<wire_cst_prepare_receive_payment_request>
|
||||||
frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request() {
|
frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request() {
|
||||||
return _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request();
|
return _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request();
|
||||||
}
|
}
|
||||||
|
|
||||||
late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_requestPtr =
|
late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_requestPtr =
|
||||||
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_prepare_receive_request> Function()>>(
|
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_prepare_receive_payment_request> Function()>>(
|
||||||
'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request');
|
'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request');
|
||||||
late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request =
|
late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_request =
|
||||||
_frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_requestPtr
|
_frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_payment_requestPtr
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_receive_request> Function()>();
|
.asFunction<ffi.Pointer<wire_cst_prepare_receive_payment_request> Function()>();
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_prepare_receive_response>
|
|
||||||
frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response() {
|
|
||||||
return _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response();
|
|
||||||
}
|
|
||||||
|
|
||||||
late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_responsePtr =
|
|
||||||
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_prepare_receive_response> Function()>>(
|
|
||||||
'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response');
|
|
||||||
late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response =
|
|
||||||
_frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_responsePtr
|
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_receive_response> Function()>();
|
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_prepare_refund_request>
|
ffi.Pointer<wire_cst_prepare_refund_request>
|
||||||
frbgen_breez_liquid_cst_new_box_autoadd_prepare_refund_request() {
|
frbgen_breez_liquid_cst_new_box_autoadd_prepare_refund_request() {
|
||||||
@@ -1115,6 +1104,18 @@ class FlutterBreezLiquidBindings {
|
|||||||
_frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_responsePtr
|
_frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_responsePtr
|
||||||
.asFunction<ffi.Pointer<wire_cst_prepare_send_response> Function()>();
|
.asFunction<ffi.Pointer<wire_cst_prepare_send_response> Function()>();
|
||||||
|
|
||||||
|
ffi.Pointer<wire_cst_receive_payment_request>
|
||||||
|
frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request() {
|
||||||
|
return _frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request();
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_requestPtr =
|
||||||
|
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_receive_payment_request> Function()>>(
|
||||||
|
'frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request');
|
||||||
|
late final _frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_request =
|
||||||
|
_frbgen_breez_liquid_cst_new_box_autoadd_receive_payment_requestPtr
|
||||||
|
.asFunction<ffi.Pointer<wire_cst_receive_payment_request> Function()>();
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_refund_request> frbgen_breez_liquid_cst_new_box_autoadd_refund_request() {
|
ffi.Pointer<wire_cst_refund_request> frbgen_breez_liquid_cst_new_box_autoadd_refund_request() {
|
||||||
return _frbgen_breez_liquid_cst_new_box_autoadd_refund_request();
|
return _frbgen_breez_liquid_cst_new_box_autoadd_refund_request();
|
||||||
}
|
}
|
||||||
@@ -1540,7 +1541,7 @@ final class wire_cst_prepare_receive_onchain_request extends ffi.Struct {
|
|||||||
external int payer_amount_sat;
|
external int payer_amount_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
final class wire_cst_prepare_receive_request extends ffi.Struct {
|
final class wire_cst_prepare_receive_payment_request extends ffi.Struct {
|
||||||
@ffi.Uint64()
|
@ffi.Uint64()
|
||||||
external int payer_amount_sat;
|
external int payer_amount_sat;
|
||||||
}
|
}
|
||||||
@@ -1566,7 +1567,7 @@ final class wire_cst_prepare_receive_onchain_response extends ffi.Struct {
|
|||||||
external int fees_sat;
|
external int fees_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
final class wire_cst_prepare_receive_response extends ffi.Struct {
|
final class wire_cst_prepare_receive_payment_response extends ffi.Struct {
|
||||||
@ffi.Uint64()
|
@ffi.Uint64()
|
||||||
external int payer_amount_sat;
|
external int payer_amount_sat;
|
||||||
|
|
||||||
@@ -1574,6 +1575,12 @@ final class wire_cst_prepare_receive_response extends ffi.Struct {
|
|||||||
external int fees_sat;
|
external int fees_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final class wire_cst_receive_payment_request extends ffi.Struct {
|
||||||
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> description;
|
||||||
|
|
||||||
|
external wire_cst_prepare_receive_payment_response prepare_res;
|
||||||
|
}
|
||||||
|
|
||||||
final class wire_cst_refund_request extends ffi.Struct {
|
final class wire_cst_refund_request extends ffi.Struct {
|
||||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> swap_address;
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> swap_address;
|
||||||
|
|
||||||
@@ -1616,6 +1623,8 @@ final class wire_cst_payment extends ffi.Struct {
|
|||||||
|
|
||||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> bolt11;
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> bolt11;
|
||||||
|
|
||||||
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> description;
|
||||||
|
|
||||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> refund_tx_id;
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> refund_tx_id;
|
||||||
|
|
||||||
external ffi.Pointer<ffi.Uint64> refund_tx_amount_sat;
|
external ffi.Pointer<ffi.Uint64> refund_tx_amount_sat;
|
||||||
|
|||||||
@@ -1205,6 +1205,7 @@ fun asPayment(payment: ReadableMap): Payment? {
|
|||||||
"feesSat",
|
"feesSat",
|
||||||
"paymentType",
|
"paymentType",
|
||||||
"status",
|
"status",
|
||||||
|
"description",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -1215,6 +1216,7 @@ fun asPayment(payment: ReadableMap): Payment? {
|
|||||||
val feesSat = payment.getDouble("feesSat").toULong()
|
val feesSat = payment.getDouble("feesSat").toULong()
|
||||||
val paymentType = payment.getString("paymentType")?.let { asPaymentType(it) }!!
|
val paymentType = payment.getString("paymentType")?.let { asPaymentType(it) }!!
|
||||||
val status = payment.getString("status")?.let { asPaymentState(it) }!!
|
val status = payment.getString("status")?.let { asPaymentState(it) }!!
|
||||||
|
val description = payment.getString("description")!!
|
||||||
val txId = if (hasNonNullKey(payment, "txId")) payment.getString("txId") else null
|
val txId = if (hasNonNullKey(payment, "txId")) payment.getString("txId") else null
|
||||||
val swapId = if (hasNonNullKey(payment, "swapId")) payment.getString("swapId") else null
|
val swapId = if (hasNonNullKey(payment, "swapId")) payment.getString("swapId") else null
|
||||||
val preimage = if (hasNonNullKey(payment, "preimage")) payment.getString("preimage") else null
|
val preimage = if (hasNonNullKey(payment, "preimage")) payment.getString("preimage") else null
|
||||||
@@ -1227,6 +1229,7 @@ fun asPayment(payment: ReadableMap): Payment? {
|
|||||||
feesSat,
|
feesSat,
|
||||||
paymentType,
|
paymentType,
|
||||||
status,
|
status,
|
||||||
|
description,
|
||||||
txId,
|
txId,
|
||||||
swapId,
|
swapId,
|
||||||
preimage,
|
preimage,
|
||||||
@@ -1243,6 +1246,7 @@ fun readableMapOf(payment: Payment): ReadableMap =
|
|||||||
"feesSat" to payment.feesSat,
|
"feesSat" to payment.feesSat,
|
||||||
"paymentType" to payment.paymentType.name.lowercase(),
|
"paymentType" to payment.paymentType.name.lowercase(),
|
||||||
"status" to payment.status.name.lowercase(),
|
"status" to payment.status.name.lowercase(),
|
||||||
|
"description" to payment.description,
|
||||||
"txId" to payment.txId,
|
"txId" to payment.txId,
|
||||||
"swapId" to payment.swapId,
|
"swapId" to payment.swapId,
|
||||||
"preimage" to payment.preimage,
|
"preimage" to payment.preimage,
|
||||||
@@ -1490,9 +1494,9 @@ fun asPrepareReceiveOnchainResponseList(arr: ReadableArray): List<PrepareReceive
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
fun asPrepareReceiveRequest(prepareReceiveRequest: ReadableMap): PrepareReceiveRequest? {
|
fun asPrepareReceivePaymentRequest(prepareReceivePaymentRequest: ReadableMap): PrepareReceivePaymentRequest? {
|
||||||
if (!validateMandatoryFields(
|
if (!validateMandatoryFields(
|
||||||
prepareReceiveRequest,
|
prepareReceivePaymentRequest,
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"payerAmountSat",
|
"payerAmountSat",
|
||||||
),
|
),
|
||||||
@@ -1500,31 +1504,31 @@ fun asPrepareReceiveRequest(prepareReceiveRequest: ReadableMap): PrepareReceiveR
|
|||||||
) {
|
) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val payerAmountSat = prepareReceiveRequest.getDouble("payerAmountSat").toULong()
|
val payerAmountSat = prepareReceivePaymentRequest.getDouble("payerAmountSat").toULong()
|
||||||
return PrepareReceiveRequest(
|
return PrepareReceivePaymentRequest(
|
||||||
payerAmountSat,
|
payerAmountSat,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readableMapOf(prepareReceiveRequest: PrepareReceiveRequest): ReadableMap =
|
fun readableMapOf(prepareReceivePaymentRequest: PrepareReceivePaymentRequest): ReadableMap =
|
||||||
readableMapOf(
|
readableMapOf(
|
||||||
"payerAmountSat" to prepareReceiveRequest.payerAmountSat,
|
"payerAmountSat" to prepareReceivePaymentRequest.payerAmountSat,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun asPrepareReceiveRequestList(arr: ReadableArray): List<PrepareReceiveRequest> {
|
fun asPrepareReceivePaymentRequestList(arr: ReadableArray): List<PrepareReceivePaymentRequest> {
|
||||||
val list = ArrayList<PrepareReceiveRequest>()
|
val list = ArrayList<PrepareReceivePaymentRequest>()
|
||||||
for (value in arr.toArrayList()) {
|
for (value in arr.toArrayList()) {
|
||||||
when (value) {
|
when (value) {
|
||||||
is ReadableMap -> list.add(asPrepareReceiveRequest(value)!!)
|
is ReadableMap -> list.add(asPrepareReceivePaymentRequest(value)!!)
|
||||||
else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}"))
|
else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
fun asPrepareReceiveResponse(prepareReceiveResponse: ReadableMap): PrepareReceiveResponse? {
|
fun asPrepareReceivePaymentResponse(prepareReceivePaymentResponse: ReadableMap): PrepareReceivePaymentResponse? {
|
||||||
if (!validateMandatoryFields(
|
if (!validateMandatoryFields(
|
||||||
prepareReceiveResponse,
|
prepareReceivePaymentResponse,
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"payerAmountSat",
|
"payerAmountSat",
|
||||||
"feesSat",
|
"feesSat",
|
||||||
@@ -1533,25 +1537,25 @@ fun asPrepareReceiveResponse(prepareReceiveResponse: ReadableMap): PrepareReceiv
|
|||||||
) {
|
) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val payerAmountSat = prepareReceiveResponse.getDouble("payerAmountSat").toULong()
|
val payerAmountSat = prepareReceivePaymentResponse.getDouble("payerAmountSat").toULong()
|
||||||
val feesSat = prepareReceiveResponse.getDouble("feesSat").toULong()
|
val feesSat = prepareReceivePaymentResponse.getDouble("feesSat").toULong()
|
||||||
return PrepareReceiveResponse(
|
return PrepareReceivePaymentResponse(
|
||||||
payerAmountSat,
|
payerAmountSat,
|
||||||
feesSat,
|
feesSat,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readableMapOf(prepareReceiveResponse: PrepareReceiveResponse): ReadableMap =
|
fun readableMapOf(prepareReceivePaymentResponse: PrepareReceivePaymentResponse): ReadableMap =
|
||||||
readableMapOf(
|
readableMapOf(
|
||||||
"payerAmountSat" to prepareReceiveResponse.payerAmountSat,
|
"payerAmountSat" to prepareReceivePaymentResponse.payerAmountSat,
|
||||||
"feesSat" to prepareReceiveResponse.feesSat,
|
"feesSat" to prepareReceivePaymentResponse.feesSat,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun asPrepareReceiveResponseList(arr: ReadableArray): List<PrepareReceiveResponse> {
|
fun asPrepareReceivePaymentResponseList(arr: ReadableArray): List<PrepareReceivePaymentResponse> {
|
||||||
val list = ArrayList<PrepareReceiveResponse>()
|
val list = ArrayList<PrepareReceivePaymentResponse>()
|
||||||
for (value in arr.toArrayList()) {
|
for (value in arr.toArrayList()) {
|
||||||
when (value) {
|
when (value) {
|
||||||
is ReadableMap -> list.add(asPrepareReceiveResponse(value)!!)
|
is ReadableMap -> list.add(asPrepareReceivePaymentResponse(value)!!)
|
||||||
else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}"))
|
else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1777,6 +1781,41 @@ fun asReceiveOnchainResponseList(arr: ReadableArray): List<ReceiveOnchainRespons
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun asReceivePaymentRequest(receivePaymentRequest: ReadableMap): ReceivePaymentRequest? {
|
||||||
|
if (!validateMandatoryFields(
|
||||||
|
receivePaymentRequest,
|
||||||
|
arrayOf(
|
||||||
|
"prepareRes",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val prepareRes = receivePaymentRequest.getMap("prepareRes")?.let { asPrepareReceivePaymentResponse(it) }!!
|
||||||
|
val description = if (hasNonNullKey(receivePaymentRequest, "description")) receivePaymentRequest.getString("description") else null
|
||||||
|
return ReceivePaymentRequest(
|
||||||
|
prepareRes,
|
||||||
|
description,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun readableMapOf(receivePaymentRequest: ReceivePaymentRequest): ReadableMap =
|
||||||
|
readableMapOf(
|
||||||
|
"prepareRes" to readableMapOf(receivePaymentRequest.prepareRes),
|
||||||
|
"description" to receivePaymentRequest.description,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun asReceivePaymentRequestList(arr: ReadableArray): List<ReceivePaymentRequest> {
|
||||||
|
val list = ArrayList<ReceivePaymentRequest>()
|
||||||
|
for (value in arr.toArrayList()) {
|
||||||
|
when (value) {
|
||||||
|
is ReadableMap -> list.add(asReceivePaymentRequest(value)!!)
|
||||||
|
else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
fun asReceivePaymentResponse(receivePaymentResponse: ReadableMap): ReceivePaymentResponse? {
|
fun asReceivePaymentResponse(receivePaymentResponse: ReadableMap): ReceivePaymentResponse? {
|
||||||
if (!validateMandatoryFields(
|
if (!validateMandatoryFields(
|
||||||
receivePaymentResponse,
|
receivePaymentResponse,
|
||||||
|
|||||||
@@ -227,10 +227,10 @@ class BreezSDKLiquidModule(
|
|||||||
) {
|
) {
|
||||||
executor.execute {
|
executor.execute {
|
||||||
try {
|
try {
|
||||||
val prepareReceiveRequest =
|
val prepareReceivePaymentRequest =
|
||||||
asPrepareReceiveRequest(req)
|
asPrepareReceivePaymentRequest(req)
|
||||||
?: run { throw SdkException.Generic(errMissingMandatoryField("req", "PrepareReceiveRequest")) }
|
?: run { throw SdkException.Generic(errMissingMandatoryField("req", "PrepareReceivePaymentRequest")) }
|
||||||
val res = getBindingLiquidSdk().prepareReceivePayment(prepareReceiveRequest)
|
val res = getBindingLiquidSdk().prepareReceivePayment(prepareReceivePaymentRequest)
|
||||||
promise.resolve(readableMapOf(res))
|
promise.resolve(readableMapOf(res))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
|
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
|
||||||
@@ -245,10 +245,10 @@ class BreezSDKLiquidModule(
|
|||||||
) {
|
) {
|
||||||
executor.execute {
|
executor.execute {
|
||||||
try {
|
try {
|
||||||
val prepareReceiveResponse =
|
val receivePaymentRequest =
|
||||||
asPrepareReceiveResponse(req)
|
asReceivePaymentRequest(req)
|
||||||
?: run { throw SdkException.Generic(errMissingMandatoryField("req", "PrepareReceiveResponse")) }
|
?: run { throw SdkException.Generic(errMissingMandatoryField("req", "ReceivePaymentRequest")) }
|
||||||
val res = getBindingLiquidSdk().receivePayment(prepareReceiveResponse)
|
val res = getBindingLiquidSdk().receivePayment(receivePaymentRequest)
|
||||||
promise.resolve(readableMapOf(res))
|
promise.resolve(readableMapOf(res))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
|
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
|
||||||
|
|||||||
2
packages/react-native/example/App.js
vendored
2
packages/react-native/example/App.js
vendored
@@ -88,7 +88,7 @@ const App = () => {
|
|||||||
// Get the fees required for this payment
|
// Get the fees required for this payment
|
||||||
addLine("Payment fees", `${prepareReceiveRes.feesSat}`)
|
addLine("Payment fees", `${prepareReceiveRes.feesSat}`)
|
||||||
|
|
||||||
let receivePaymentRes = await receivePayment(prepareReceiveRes)
|
let receivePaymentRes = await receivePayment({prepareRes: prepareReceiveRes})
|
||||||
addLine("receivePayment", JSON.stringify(receivePaymentRes))
|
addLine("receivePayment", JSON.stringify(receivePaymentRes))
|
||||||
// Wait for payer to pay.... once successfully paid an event of `paymentSucceeded` will be emitted.
|
// Wait for payer to pay.... once successfully paid an event of `paymentSucceeded` will be emitted.
|
||||||
addLine("Bolt11 invoice", `${receivePaymentRes.invoice}`)
|
addLine("Bolt11 invoice", `${receivePaymentRes.invoice}`)
|
||||||
|
|||||||
@@ -1423,6 +1423,9 @@ enum BreezSDKLiquidMapper {
|
|||||||
}
|
}
|
||||||
let status = try asPaymentState(paymentState: statusTmp)
|
let status = try asPaymentState(paymentState: statusTmp)
|
||||||
|
|
||||||
|
guard let description = payment["description"] as? String else {
|
||||||
|
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "description", typeName: "Payment"))
|
||||||
|
}
|
||||||
var txId: String?
|
var txId: String?
|
||||||
if hasNonNilKey(data: payment, key: "txId") {
|
if hasNonNilKey(data: payment, key: "txId") {
|
||||||
guard let txIdTmp = payment["txId"] as? String else {
|
guard let txIdTmp = payment["txId"] as? String else {
|
||||||
@@ -1472,6 +1475,7 @@ enum BreezSDKLiquidMapper {
|
|||||||
feesSat: feesSat,
|
feesSat: feesSat,
|
||||||
paymentType: paymentType,
|
paymentType: paymentType,
|
||||||
status: status,
|
status: status,
|
||||||
|
description: description,
|
||||||
txId: txId,
|
txId: txId,
|
||||||
swapId: swapId,
|
swapId: swapId,
|
||||||
preimage: preimage,
|
preimage: preimage,
|
||||||
@@ -1488,6 +1492,7 @@ enum BreezSDKLiquidMapper {
|
|||||||
"feesSat": payment.feesSat,
|
"feesSat": payment.feesSat,
|
||||||
"paymentType": valueOf(paymentType: payment.paymentType),
|
"paymentType": valueOf(paymentType: payment.paymentType),
|
||||||
"status": valueOf(paymentState: payment.status),
|
"status": valueOf(paymentState: payment.status),
|
||||||
|
"description": payment.description,
|
||||||
"txId": payment.txId == nil ? nil : payment.txId,
|
"txId": payment.txId == nil ? nil : payment.txId,
|
||||||
"swapId": payment.swapId == nil ? nil : payment.swapId,
|
"swapId": payment.swapId == nil ? nil : payment.swapId,
|
||||||
"preimage": payment.preimage == nil ? nil : payment.preimage,
|
"preimage": payment.preimage == nil ? nil : payment.preimage,
|
||||||
@@ -1754,74 +1759,74 @@ enum BreezSDKLiquidMapper {
|
|||||||
return prepareReceiveOnchainResponseList.map { v -> [String: Any?] in return dictionaryOf(prepareReceiveOnchainResponse: v) }
|
return prepareReceiveOnchainResponseList.map { v -> [String: Any?] in return dictionaryOf(prepareReceiveOnchainResponse: v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func asPrepareReceiveRequest(prepareReceiveRequest: [String: Any?]) throws -> PrepareReceiveRequest {
|
static func asPrepareReceivePaymentRequest(prepareReceivePaymentRequest: [String: Any?]) throws -> PrepareReceivePaymentRequest {
|
||||||
guard let payerAmountSat = prepareReceiveRequest["payerAmountSat"] as? UInt64 else {
|
guard let payerAmountSat = prepareReceivePaymentRequest["payerAmountSat"] as? UInt64 else {
|
||||||
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "payerAmountSat", typeName: "PrepareReceiveRequest"))
|
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "payerAmountSat", typeName: "PrepareReceivePaymentRequest"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return PrepareReceiveRequest(
|
return PrepareReceivePaymentRequest(
|
||||||
payerAmountSat: payerAmountSat)
|
payerAmountSat: payerAmountSat)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func dictionaryOf(prepareReceiveRequest: PrepareReceiveRequest) -> [String: Any?] {
|
static func dictionaryOf(prepareReceivePaymentRequest: PrepareReceivePaymentRequest) -> [String: Any?] {
|
||||||
return [
|
return [
|
||||||
"payerAmountSat": prepareReceiveRequest.payerAmountSat,
|
"payerAmountSat": prepareReceivePaymentRequest.payerAmountSat,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static func asPrepareReceiveRequestList(arr: [Any]) throws -> [PrepareReceiveRequest] {
|
static func asPrepareReceivePaymentRequestList(arr: [Any]) throws -> [PrepareReceivePaymentRequest] {
|
||||||
var list = [PrepareReceiveRequest]()
|
var list = [PrepareReceivePaymentRequest]()
|
||||||
for value in arr {
|
for value in arr {
|
||||||
if let val = value as? [String: Any?] {
|
if let val = value as? [String: Any?] {
|
||||||
var prepareReceiveRequest = try asPrepareReceiveRequest(prepareReceiveRequest: val)
|
var prepareReceivePaymentRequest = try asPrepareReceivePaymentRequest(prepareReceivePaymentRequest: val)
|
||||||
list.append(prepareReceiveRequest)
|
list.append(prepareReceivePaymentRequest)
|
||||||
} else {
|
} else {
|
||||||
throw SdkError.Generic(message: errUnexpectedType(typeName: "PrepareReceiveRequest"))
|
throw SdkError.Generic(message: errUnexpectedType(typeName: "PrepareReceivePaymentRequest"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
static func arrayOf(prepareReceiveRequestList: [PrepareReceiveRequest]) -> [Any] {
|
static func arrayOf(prepareReceivePaymentRequestList: [PrepareReceivePaymentRequest]) -> [Any] {
|
||||||
return prepareReceiveRequestList.map { v -> [String: Any?] in return dictionaryOf(prepareReceiveRequest: v) }
|
return prepareReceivePaymentRequestList.map { v -> [String: Any?] in return dictionaryOf(prepareReceivePaymentRequest: v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func asPrepareReceiveResponse(prepareReceiveResponse: [String: Any?]) throws -> PrepareReceiveResponse {
|
static func asPrepareReceivePaymentResponse(prepareReceivePaymentResponse: [String: Any?]) throws -> PrepareReceivePaymentResponse {
|
||||||
guard let payerAmountSat = prepareReceiveResponse["payerAmountSat"] as? UInt64 else {
|
guard let payerAmountSat = prepareReceivePaymentResponse["payerAmountSat"] as? UInt64 else {
|
||||||
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "payerAmountSat", typeName: "PrepareReceiveResponse"))
|
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "payerAmountSat", typeName: "PrepareReceivePaymentResponse"))
|
||||||
}
|
}
|
||||||
guard let feesSat = prepareReceiveResponse["feesSat"] as? UInt64 else {
|
guard let feesSat = prepareReceivePaymentResponse["feesSat"] as? UInt64 else {
|
||||||
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesSat", typeName: "PrepareReceiveResponse"))
|
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesSat", typeName: "PrepareReceivePaymentResponse"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return PrepareReceiveResponse(
|
return PrepareReceivePaymentResponse(
|
||||||
payerAmountSat: payerAmountSat,
|
payerAmountSat: payerAmountSat,
|
||||||
feesSat: feesSat
|
feesSat: feesSat
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func dictionaryOf(prepareReceiveResponse: PrepareReceiveResponse) -> [String: Any?] {
|
static func dictionaryOf(prepareReceivePaymentResponse: PrepareReceivePaymentResponse) -> [String: Any?] {
|
||||||
return [
|
return [
|
||||||
"payerAmountSat": prepareReceiveResponse.payerAmountSat,
|
"payerAmountSat": prepareReceivePaymentResponse.payerAmountSat,
|
||||||
"feesSat": prepareReceiveResponse.feesSat,
|
"feesSat": prepareReceivePaymentResponse.feesSat,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static func asPrepareReceiveResponseList(arr: [Any]) throws -> [PrepareReceiveResponse] {
|
static func asPrepareReceivePaymentResponseList(arr: [Any]) throws -> [PrepareReceivePaymentResponse] {
|
||||||
var list = [PrepareReceiveResponse]()
|
var list = [PrepareReceivePaymentResponse]()
|
||||||
for value in arr {
|
for value in arr {
|
||||||
if let val = value as? [String: Any?] {
|
if let val = value as? [String: Any?] {
|
||||||
var prepareReceiveResponse = try asPrepareReceiveResponse(prepareReceiveResponse: val)
|
var prepareReceivePaymentResponse = try asPrepareReceivePaymentResponse(prepareReceivePaymentResponse: val)
|
||||||
list.append(prepareReceiveResponse)
|
list.append(prepareReceivePaymentResponse)
|
||||||
} else {
|
} else {
|
||||||
throw SdkError.Generic(message: errUnexpectedType(typeName: "PrepareReceiveResponse"))
|
throw SdkError.Generic(message: errUnexpectedType(typeName: "PrepareReceivePaymentResponse"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
static func arrayOf(prepareReceiveResponseList: [PrepareReceiveResponse]) -> [Any] {
|
static func arrayOf(prepareReceivePaymentResponseList: [PrepareReceivePaymentResponse]) -> [Any] {
|
||||||
return prepareReceiveResponseList.map { v -> [String: Any?] in return dictionaryOf(prepareReceiveResponse: v) }
|
return prepareReceivePaymentResponseList.map { v -> [String: Any?] in return dictionaryOf(prepareReceivePaymentResponse: v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func asPrepareRefundRequest(prepareRefundRequest: [String: Any?]) throws -> PrepareRefundRequest {
|
static func asPrepareRefundRequest(prepareRefundRequest: [String: Any?]) throws -> PrepareRefundRequest {
|
||||||
@@ -2060,6 +2065,50 @@ enum BreezSDKLiquidMapper {
|
|||||||
return receiveOnchainResponseList.map { v -> [String: Any?] in return dictionaryOf(receiveOnchainResponse: v) }
|
return receiveOnchainResponseList.map { v -> [String: Any?] in return dictionaryOf(receiveOnchainResponse: v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func asReceivePaymentRequest(receivePaymentRequest: [String: Any?]) throws -> ReceivePaymentRequest {
|
||||||
|
guard let prepareResTmp = receivePaymentRequest["prepareRes"] as? [String: Any?] else {
|
||||||
|
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "prepareRes", typeName: "ReceivePaymentRequest"))
|
||||||
|
}
|
||||||
|
let prepareRes = try asPrepareReceivePaymentResponse(prepareReceivePaymentResponse: prepareResTmp)
|
||||||
|
|
||||||
|
var description: String?
|
||||||
|
if hasNonNilKey(data: receivePaymentRequest, key: "description") {
|
||||||
|
guard let descriptionTmp = receivePaymentRequest["description"] as? String else {
|
||||||
|
throw SdkError.Generic(message: errUnexpectedValue(fieldName: "description"))
|
||||||
|
}
|
||||||
|
description = descriptionTmp
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReceivePaymentRequest(
|
||||||
|
prepareRes: prepareRes,
|
||||||
|
description: description
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func dictionaryOf(receivePaymentRequest: ReceivePaymentRequest) -> [String: Any?] {
|
||||||
|
return [
|
||||||
|
"prepareRes": dictionaryOf(prepareReceivePaymentResponse: receivePaymentRequest.prepareRes),
|
||||||
|
"description": receivePaymentRequest.description == nil ? nil : receivePaymentRequest.description,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
static func asReceivePaymentRequestList(arr: [Any]) throws -> [ReceivePaymentRequest] {
|
||||||
|
var list = [ReceivePaymentRequest]()
|
||||||
|
for value in arr {
|
||||||
|
if let val = value as? [String: Any?] {
|
||||||
|
var receivePaymentRequest = try asReceivePaymentRequest(receivePaymentRequest: val)
|
||||||
|
list.append(receivePaymentRequest)
|
||||||
|
} else {
|
||||||
|
throw SdkError.Generic(message: errUnexpectedType(typeName: "ReceivePaymentRequest"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
static func arrayOf(receivePaymentRequestList: [ReceivePaymentRequest]) -> [Any] {
|
||||||
|
return receivePaymentRequestList.map { v -> [String: Any?] in return dictionaryOf(receivePaymentRequest: v) }
|
||||||
|
}
|
||||||
|
|
||||||
static func asReceivePaymentResponse(receivePaymentResponse: [String: Any?]) throws -> ReceivePaymentResponse {
|
static func asReceivePaymentResponse(receivePaymentResponse: [String: Any?]) throws -> ReceivePaymentResponse {
|
||||||
guard let id = receivePaymentResponse["id"] as? String else {
|
guard let id = receivePaymentResponse["id"] as? String else {
|
||||||
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "id", typeName: "ReceivePaymentResponse"))
|
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "id", typeName: "ReceivePaymentResponse"))
|
||||||
|
|||||||
@@ -189,9 +189,9 @@ class RNBreezSDKLiquid: RCTEventEmitter {
|
|||||||
@objc(prepareReceivePayment:resolve:reject:)
|
@objc(prepareReceivePayment:resolve:reject:)
|
||||||
func prepareReceivePayment(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
func prepareReceivePayment(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||||
do {
|
do {
|
||||||
let prepareReceiveRequest = try BreezSDKLiquidMapper.asPrepareReceiveRequest(prepareReceiveRequest: req)
|
let prepareReceivePaymentRequest = try BreezSDKLiquidMapper.asPrepareReceivePaymentRequest(prepareReceivePaymentRequest: req)
|
||||||
var res = try getBindingLiquidSdk().prepareReceivePayment(req: prepareReceiveRequest)
|
var res = try getBindingLiquidSdk().prepareReceivePayment(req: prepareReceivePaymentRequest)
|
||||||
resolve(BreezSDKLiquidMapper.dictionaryOf(prepareReceiveResponse: res))
|
resolve(BreezSDKLiquidMapper.dictionaryOf(prepareReceivePaymentResponse: res))
|
||||||
} catch let err {
|
} catch let err {
|
||||||
rejectErr(err: err, reject: reject)
|
rejectErr(err: err, reject: reject)
|
||||||
}
|
}
|
||||||
@@ -200,8 +200,8 @@ class RNBreezSDKLiquid: RCTEventEmitter {
|
|||||||
@objc(receivePayment:resolve:reject:)
|
@objc(receivePayment:resolve:reject:)
|
||||||
func receivePayment(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
func receivePayment(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||||
do {
|
do {
|
||||||
let prepareReceiveResponse = try BreezSDKLiquidMapper.asPrepareReceiveResponse(prepareReceiveResponse: req)
|
let receivePaymentRequest = try BreezSDKLiquidMapper.asReceivePaymentRequest(receivePaymentRequest: req)
|
||||||
var res = try getBindingLiquidSdk().receivePayment(req: prepareReceiveResponse)
|
var res = try getBindingLiquidSdk().receivePayment(req: receivePaymentRequest)
|
||||||
resolve(BreezSDKLiquidMapper.dictionaryOf(receivePaymentResponse: res))
|
resolve(BreezSDKLiquidMapper.dictionaryOf(receivePaymentResponse: res))
|
||||||
} catch let err {
|
} catch let err {
|
||||||
rejectErr(err: err, reject: reject)
|
rejectErr(err: err, reject: reject)
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ export interface Payment {
|
|||||||
feesSat: number
|
feesSat: number
|
||||||
paymentType: PaymentType
|
paymentType: PaymentType
|
||||||
status: PaymentState
|
status: PaymentState
|
||||||
|
description: string
|
||||||
txId?: string
|
txId?: string
|
||||||
swapId?: string
|
swapId?: string
|
||||||
preimage?: string
|
preimage?: string
|
||||||
@@ -247,11 +248,11 @@ export interface PrepareReceiveOnchainResponse {
|
|||||||
feesSat: number
|
feesSat: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrepareReceiveRequest {
|
export interface PrepareReceivePaymentRequest {
|
||||||
payerAmountSat: number
|
payerAmountSat: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrepareReceiveResponse {
|
export interface PrepareReceivePaymentResponse {
|
||||||
payerAmountSat: number
|
payerAmountSat: number
|
||||||
feesSat: number
|
feesSat: number
|
||||||
}
|
}
|
||||||
@@ -287,6 +288,11 @@ export interface ReceiveOnchainResponse {
|
|||||||
bip21: string
|
bip21: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReceivePaymentRequest {
|
||||||
|
prepareRes: PrepareReceivePaymentResponse
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface ReceivePaymentResponse {
|
export interface ReceivePaymentResponse {
|
||||||
id: string
|
id: string
|
||||||
invoice: string
|
invoice: string
|
||||||
@@ -588,12 +594,12 @@ export const sendPayment = async (req: PrepareSendResponse): Promise<SendPayment
|
|||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
export const prepareReceivePayment = async (req: PrepareReceiveRequest): Promise<PrepareReceiveResponse> => {
|
export const prepareReceivePayment = async (req: PrepareReceivePaymentRequest): Promise<PrepareReceivePaymentResponse> => {
|
||||||
const response = await BreezSDKLiquid.prepareReceivePayment(req)
|
const response = await BreezSDKLiquid.prepareReceivePayment(req)
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
export const receivePayment = async (req: PrepareReceiveResponse): Promise<ReceivePaymentResponse> => {
|
export const receivePayment = async (req: ReceivePaymentRequest): Promise<ReceivePaymentResponse> => {
|
||||||
const response = await BreezSDKLiquid.receivePayment(req)
|
const response = await BreezSDKLiquid.receivePayment(req)
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user