mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-23 08:54:22 +01:00
Receive Chain Swaps (#310)
* Implement Chain Swaps for receiving * Send: validate if we have sufficient funds (#321) * Implement Chain Swaps for receiving * Fix rebase of flutter_rust_bridge version * Send: validate if we have sufficient funds * Re-generate FRB --------- Co-authored-by: Ross Savage <hello@satimoto.com> * Chaim swap claim: remove refund_tx arg (#328) --------- Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
This commit is contained in:
@@ -409,6 +409,12 @@ enum PaymentState {
|
||||
/// This covers the case when the swap state is still Created and the swap fails to reach the
|
||||
/// Pending state in time. The TimedOut state indicates the lockup tx should never be broadcast.
|
||||
timedOut,
|
||||
|
||||
/// ## Incoming Chain Swaps
|
||||
///
|
||||
/// This covers the case when the swap failed for any reason and there is a user lockup tx.
|
||||
/// The swap in this case has to be manually refunded with a provided Bitcoin address
|
||||
refundable,
|
||||
;
|
||||
}
|
||||
|
||||
@@ -455,6 +461,45 @@ class PreparePayOnchainResponse {
|
||||
feesSat == other.feesSat;
|
||||
}
|
||||
|
||||
class PrepareReceiveOnchainRequest {
|
||||
final BigInt amountSat;
|
||||
|
||||
const PrepareReceiveOnchainRequest({
|
||||
required this.amountSat,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => amountSat.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is PrepareReceiveOnchainRequest &&
|
||||
runtimeType == other.runtimeType &&
|
||||
amountSat == other.amountSat;
|
||||
}
|
||||
|
||||
class PrepareReceiveOnchainResponse {
|
||||
final BigInt amountSat;
|
||||
final BigInt feesSat;
|
||||
|
||||
const PrepareReceiveOnchainResponse({
|
||||
required this.amountSat,
|
||||
required this.feesSat,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => amountSat.hashCode ^ feesSat.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is PrepareReceiveOnchainResponse &&
|
||||
runtimeType == other.runtimeType &&
|
||||
amountSat == other.amountSat &&
|
||||
feesSat == other.feesSat;
|
||||
}
|
||||
|
||||
class PrepareReceiveRequest {
|
||||
final BigInt payerAmountSat;
|
||||
|
||||
@@ -494,6 +539,51 @@ class PrepareReceiveResponse {
|
||||
feesSat == other.feesSat;
|
||||
}
|
||||
|
||||
class PrepareRefundRequest {
|
||||
final String swapAddress;
|
||||
final String refundAddress;
|
||||
final int satPerVbyte;
|
||||
|
||||
const PrepareRefundRequest({
|
||||
required this.swapAddress,
|
||||
required this.refundAddress,
|
||||
required this.satPerVbyte,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => swapAddress.hashCode ^ refundAddress.hashCode ^ satPerVbyte.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is PrepareRefundRequest &&
|
||||
runtimeType == other.runtimeType &&
|
||||
swapAddress == other.swapAddress &&
|
||||
refundAddress == other.refundAddress &&
|
||||
satPerVbyte == other.satPerVbyte;
|
||||
}
|
||||
|
||||
class PrepareRefundResponse {
|
||||
final int refundTxVsize;
|
||||
final BigInt refundTxFeeSat;
|
||||
|
||||
const PrepareRefundResponse({
|
||||
required this.refundTxVsize,
|
||||
required this.refundTxFeeSat,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => refundTxVsize.hashCode ^ refundTxFeeSat.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is PrepareRefundResponse &&
|
||||
runtimeType == other.runtimeType &&
|
||||
refundTxVsize == other.refundTxVsize &&
|
||||
refundTxFeeSat == other.refundTxFeeSat;
|
||||
}
|
||||
|
||||
class PrepareSendRequest {
|
||||
final String invoice;
|
||||
|
||||
@@ -531,6 +621,43 @@ class PrepareSendResponse {
|
||||
feesSat == other.feesSat;
|
||||
}
|
||||
|
||||
class ReceiveOnchainRequest {
|
||||
final PrepareReceiveOnchainResponse prepareRes;
|
||||
|
||||
const ReceiveOnchainRequest({
|
||||
required this.prepareRes,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => prepareRes.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ReceiveOnchainRequest && runtimeType == other.runtimeType && prepareRes == other.prepareRes;
|
||||
}
|
||||
|
||||
class ReceiveOnchainResponse {
|
||||
final String address;
|
||||
final String bip21;
|
||||
|
||||
const ReceiveOnchainResponse({
|
||||
required this.address,
|
||||
required this.bip21,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => address.hashCode ^ bip21.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ReceiveOnchainResponse &&
|
||||
runtimeType == other.runtimeType &&
|
||||
address == other.address &&
|
||||
bip21 == other.bip21;
|
||||
}
|
||||
|
||||
class ReceivePaymentResponse {
|
||||
final String id;
|
||||
final String invoice;
|
||||
@@ -552,6 +679,70 @@ class ReceivePaymentResponse {
|
||||
invoice == other.invoice;
|
||||
}
|
||||
|
||||
class RefundRequest {
|
||||
final String swapAddress;
|
||||
final String refundAddress;
|
||||
final int satPerVbyte;
|
||||
|
||||
const RefundRequest({
|
||||
required this.swapAddress,
|
||||
required this.refundAddress,
|
||||
required this.satPerVbyte,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => swapAddress.hashCode ^ refundAddress.hashCode ^ satPerVbyte.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is RefundRequest &&
|
||||
runtimeType == other.runtimeType &&
|
||||
swapAddress == other.swapAddress &&
|
||||
refundAddress == other.refundAddress &&
|
||||
satPerVbyte == other.satPerVbyte;
|
||||
}
|
||||
|
||||
class RefundResponse {
|
||||
final String refundTxId;
|
||||
|
||||
const RefundResponse({
|
||||
required this.refundTxId,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => refundTxId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is RefundResponse && runtimeType == other.runtimeType && refundTxId == other.refundTxId;
|
||||
}
|
||||
|
||||
class RefundableSwap {
|
||||
final String swapAddress;
|
||||
final int timestamp;
|
||||
final BigInt amountSat;
|
||||
|
||||
const RefundableSwap({
|
||||
required this.swapAddress,
|
||||
required this.timestamp,
|
||||
required this.amountSat,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => swapAddress.hashCode ^ timestamp.hashCode ^ amountSat.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is RefundableSwap &&
|
||||
runtimeType == other.runtimeType &&
|
||||
swapAddress == other.swapAddress &&
|
||||
timestamp == other.timestamp &&
|
||||
amountSat == other.amountSat;
|
||||
}
|
||||
|
||||
class RestoreRequest {
|
||||
final String? backupPath;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user