mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-23 08:54:22 +01:00
Liquid/Lightning drain (#553)
* Attempt drain using liquid or lightning payment * Optimize estimation handling, use address in drain estimation * Add drain option to PrepareSendRequest * Block draining while there are pending payments * Apply suggestions from code review * Rename PayOnchainAmount to PayAmount
This commit is contained in:
@@ -476,16 +476,16 @@ class OnchainPaymentLimitsResponse {
|
||||
}
|
||||
|
||||
@freezed
|
||||
sealed class PayOnchainAmount with _$PayOnchainAmount {
|
||||
const PayOnchainAmount._();
|
||||
sealed class PayAmount with _$PayAmount {
|
||||
const PayAmount._();
|
||||
|
||||
/// The amount in satoshi that will be received
|
||||
const factory PayOnchainAmount.receiver({
|
||||
const factory PayAmount.receiver({
|
||||
required BigInt amountSat,
|
||||
}) = PayOnchainAmount_Receiver;
|
||||
}) = PayAmount_Receiver;
|
||||
|
||||
/// Indicates that all available funds should be sent
|
||||
const factory PayOnchainAmount.drain() = PayOnchainAmount_Drain;
|
||||
const factory PayAmount.drain() = PayAmount_Drain;
|
||||
}
|
||||
|
||||
/// An argument when calling [crate::sdk::LiquidSdk::pay_onchain].
|
||||
@@ -849,7 +849,7 @@ class PrepareLnUrlPayResponse {
|
||||
|
||||
/// An argument when calling [crate::sdk::LiquidSdk::prepare_pay_onchain].
|
||||
class PreparePayOnchainRequest {
|
||||
final PayOnchainAmount amount;
|
||||
final PayAmount amount;
|
||||
|
||||
/// The optional fee rate of the Bitcoin claim transaction in sat/vB. Defaults to the swapper estimated claim fee.
|
||||
final int? feeRateSatPerVbyte;
|
||||
@@ -1005,16 +1005,16 @@ class PrepareSendRequest {
|
||||
final String destination;
|
||||
|
||||
/// Should only be set when paying directly onchain or to a BIP21 URI
|
||||
/// where no amount is specified
|
||||
final BigInt? amountSat;
|
||||
/// where no amount is specified, or when the caller wishes to drain
|
||||
final PayAmount? amount;
|
||||
|
||||
const PrepareSendRequest({
|
||||
required this.destination,
|
||||
this.amountSat,
|
||||
this.amount,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => destination.hashCode ^ amountSat.hashCode;
|
||||
int get hashCode => destination.hashCode ^ amount.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@@ -1022,7 +1022,7 @@ class PrepareSendRequest {
|
||||
other is PrepareSendRequest &&
|
||||
runtimeType == other.runtimeType &&
|
||||
destination == other.destination &&
|
||||
amountSat == other.amountSat;
|
||||
amount == other.amount;
|
||||
}
|
||||
|
||||
/// Returned when calling [crate::sdk::LiquidSdk::prepare_send_payment].
|
||||
|
||||
Reference in New Issue
Block a user