mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-23 08:54:22 +01:00
prepare-pay-onchain: add option for drain (#464)
* prepare-pay-onchain: add option for drain in req * Fix clippy * ChainSwapStateHandler: gracefully handle building both drain and non-drain lockups * Send Chain swap: use standard feerate when estimating lockup tx fee * UDL: move new drain field above the last PreparePayOnchainRequest optional field * UDL: move new drain field optional * prepare-pay-onchain: treat normal payment as drain if receiver amount is high enough If the receiver amount is as high as it would be in case of drain, treat the current prepare-pay-onchain as drain, even if the drain flag is not set. * build_drain_tx: add optional amount validation * Add PayOnchainAmount enum to cover amount types (drain, receiver) * Add ability to find max_receiver_amount_sat for non-drain sends * Revert "Add ability to find max_receiver_amount_sat for non-drain sends" This reverts commit 60ee1c768021810f72bc64a8ada69d35b638185e. * prepare_pay_onchain: treat drain and non-drain cases separately If the non-drain case is chosen with a receiver_amount equivalent to what drain would have calculated, it results in an error. For drain, the caller has to explicitly choose PayOnchainAmount::Drain. * CLI: send-onchain-payment accepts optional amount * CLI: add docs for send-onchain-payment drain arg * SDK: expand docs for prepare_pay_onchain * Re-generate RN bindings * Re-generate flutter bindings
This commit is contained in:
@@ -405,6 +405,19 @@ class OnchainPaymentLimitsResponse {
|
||||
receive == other.receive;
|
||||
}
|
||||
|
||||
@freezed
|
||||
sealed class PayOnchainAmount with _$PayOnchainAmount {
|
||||
const PayOnchainAmount._();
|
||||
|
||||
/// The amount in satoshi that will be received
|
||||
const factory PayOnchainAmount.receiver({
|
||||
required BigInt amountSat,
|
||||
}) = PayOnchainAmount_Receiver;
|
||||
|
||||
/// Indicates that all available funds should be sent
|
||||
const factory PayOnchainAmount.drain() = PayOnchainAmount_Drain;
|
||||
}
|
||||
|
||||
/// An argument when calling [crate::sdk::LiquidSdk::pay_onchain].
|
||||
class PayOnchainRequest {
|
||||
final String address;
|
||||
@@ -695,23 +708,25 @@ class PrepareBuyBitcoinResponse {
|
||||
|
||||
/// An argument when calling [crate::sdk::LiquidSdk::prepare_pay_onchain].
|
||||
class PreparePayOnchainRequest {
|
||||
final BigInt receiverAmountSat;
|
||||
final PayOnchainAmount amount;
|
||||
|
||||
/// The optional fee rate of the Bitcoin claim transaction. Defaults to the swapper estimated claim fee.
|
||||
final int? satPerVbyte;
|
||||
|
||||
const PreparePayOnchainRequest({
|
||||
required this.receiverAmountSat,
|
||||
required this.amount,
|
||||
this.satPerVbyte,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => receiverAmountSat.hashCode ^ satPerVbyte.hashCode;
|
||||
int get hashCode => amount.hashCode ^ satPerVbyte.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is PreparePayOnchainRequest &&
|
||||
runtimeType == other.runtimeType &&
|
||||
receiverAmountSat == other.receiverAmountSat &&
|
||||
amount == other.amount &&
|
||||
satPerVbyte == other.satPerVbyte;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user