From 177127d3764fb2c35d9e6f07e825d491a7aa2c44 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Wed, 15 May 2024 09:41:06 +0200 Subject: [PATCH] Update flutter bindings --- .../include/breez_liquid_sdk.h | 14 +- lib/core/src/frb/bridge.io.rs | 56 +-- lib/core/src/frb/bridge.rs | 118 +++--- packages/dart/lib/src/bindings.dart | 19 - packages/dart/lib/src/error.dart | 16 +- packages/dart/lib/src/error.freezed.dart | 378 +++++++++--------- packages/dart/lib/src/frb_generated.dart | 251 +++--------- packages/dart/lib/src/frb_generated.io.dart | 167 ++------ packages/dart/lib/src/model.dart | 35 +- 9 files changed, 390 insertions(+), 664 deletions(-) diff --git a/lib/bindings/bindings-flutter/breez_liquid_sdk/include/breez_liquid_sdk.h b/lib/bindings/bindings-flutter/breez_liquid_sdk/include/breez_liquid_sdk.h index 6e04c2f..b7f3b17 100644 --- a/lib/bindings/bindings-flutter/breez_liquid_sdk/include/breez_liquid_sdk.h +++ b/lib/bindings/bindings-flutter/breez_liquid_sdk/include/breez_liquid_sdk.h @@ -18,7 +18,7 @@ typedef struct _Dart_Handle* Dart_Handle; * Claim tx feerate, in sats per vbyte. * Since the Liquid blocks are consistently empty for now, we hardcode the minimum feerate. */ -#define LIQUID_CLAIM_TX_FEERATE 0.1 +#define LIQUID_CLAIM_TX_FEERATE_MSAT 100.0 typedef struct wire_cst_list_prim_u_8_strict { uint8_t *ptr; @@ -76,11 +76,6 @@ typedef struct wire_cst_get_info_response { struct wire_cst_list_prim_u_8_strict *pubkey; } wire_cst_get_info_response; -typedef struct wire_cst_PaymentError_Refunded { - struct wire_cst_list_prim_u_8_strict *err; - struct wire_cst_list_prim_u_8_strict *txid; -} wire_cst_PaymentError_Refunded; - typedef struct wire_cst_PaymentError_Generic { struct wire_cst_list_prim_u_8_strict *err; } wire_cst_PaymentError_Generic; @@ -89,6 +84,11 @@ typedef struct wire_cst_PaymentError_LwkError { struct wire_cst_list_prim_u_8_strict *err; } wire_cst_PaymentError_LwkError; +typedef struct wire_cst_PaymentError_Refunded { + struct wire_cst_list_prim_u_8_strict *err; + struct wire_cst_list_prim_u_8_strict *txid; +} wire_cst_PaymentError_Refunded; + typedef struct wire_cst_PaymentError_SendError { struct wire_cst_list_prim_u_8_strict *err; } wire_cst_PaymentError_SendError; @@ -98,9 +98,9 @@ typedef struct wire_cst_PaymentError_SignerError { } wire_cst_PaymentError_SignerError; typedef union PaymentErrorKind { - struct wire_cst_PaymentError_Refunded Refunded; struct wire_cst_PaymentError_Generic Generic; struct wire_cst_PaymentError_LwkError LwkError; + struct wire_cst_PaymentError_Refunded Refunded; struct wire_cst_PaymentError_SendError SendError; struct wire_cst_PaymentError_SignerError SignerError; } PaymentErrorKind; diff --git a/lib/core/src/frb/bridge.io.rs b/lib/core/src/frb/bridge.io.rs index caf4a19..ce276ad 100644 --- a/lib/core/src/frb/bridge.io.rs +++ b/lib/core/src/frb/bridge.io.rs @@ -153,33 +153,33 @@ impl CstDecode for wire_cst_payment_error { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> crate::error::PaymentError { match self.tag { - 0 => crate::error::PaymentError::AmountOutOfRange, - 1 => crate::error::PaymentError::InvalidOrExpiredFees, - 2 => crate::error::PaymentError::InsufficientFunds, - 3 => crate::error::PaymentError::AlreadyClaimed, - 4 => { + 0 => crate::error::PaymentError::AlreadyClaimed, + 1 => crate::error::PaymentError::AmountOutOfRange, + 2 => { + let ans = unsafe { self.kind.Generic }; + crate::error::PaymentError::Generic { + err: ans.err.cst_decode(), + } + } + 3 => crate::error::PaymentError::InvalidOrExpiredFees, + 4 => crate::error::PaymentError::InsufficientFunds, + 5 => crate::error::PaymentError::InvalidInvoice, + 6 => crate::error::PaymentError::InvalidPreimage, + 7 => { + let ans = unsafe { self.kind.LwkError }; + crate::error::PaymentError::LwkError { + err: ans.err.cst_decode(), + } + } + 8 => crate::error::PaymentError::PairsNotFound, + 9 => crate::error::PaymentError::PersistError, + 10 => { let ans = unsafe { self.kind.Refunded }; crate::error::PaymentError::Refunded { err: ans.err.cst_decode(), txid: ans.txid.cst_decode(), } } - 5 => { - let ans = unsafe { self.kind.Generic }; - crate::error::PaymentError::Generic { - err: ans.err.cst_decode(), - } - } - 6 => crate::error::PaymentError::InvalidInvoice, - 7 => crate::error::PaymentError::InvalidPreimage, - 8 => { - let ans = unsafe { self.kind.LwkError }; - crate::error::PaymentError::LwkError { - err: ans.err.cst_decode(), - } - } - 9 => crate::error::PaymentError::PairsNotFound, - 10 => crate::error::PaymentError::PersistError, 11 => { let ans = unsafe { self.kind.SendError }; crate::error::PaymentError::SendError { @@ -619,21 +619,15 @@ pub struct wire_cst_payment_error { #[repr(C)] #[derive(Clone, Copy)] pub union PaymentErrorKind { - Refunded: wire_cst_PaymentError_Refunded, Generic: wire_cst_PaymentError_Generic, LwkError: wire_cst_PaymentError_LwkError, + Refunded: wire_cst_PaymentError_Refunded, SendError: wire_cst_PaymentError_SendError, SignerError: wire_cst_PaymentError_SignerError, nil__: (), } #[repr(C)] #[derive(Clone, Copy)] -pub struct wire_cst_PaymentError_Refunded { - err: *mut wire_cst_list_prim_u_8_strict, - txid: *mut wire_cst_list_prim_u_8_strict, -} -#[repr(C)] -#[derive(Clone, Copy)] pub struct wire_cst_PaymentError_Generic { err: *mut wire_cst_list_prim_u_8_strict, } @@ -644,6 +638,12 @@ pub struct wire_cst_PaymentError_LwkError { } #[repr(C)] #[derive(Clone, Copy)] +pub struct wire_cst_PaymentError_Refunded { + err: *mut wire_cst_list_prim_u_8_strict, + txid: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] pub struct wire_cst_PaymentError_SendError { err: *mut wire_cst_list_prim_u_8_strict, } diff --git a/lib/core/src/frb/bridge.rs b/lib/core/src/frb/bridge.rs index af537e7..25a1212 100644 --- a/lib/core/src/frb/bridge.rs +++ b/lib/core/src/frb/bridge.rs @@ -416,18 +416,38 @@ impl SseDecode for crate::error::PaymentError { let mut tag_ = ::sse_decode(deserializer); match tag_ { 0 => { - return crate::error::PaymentError::AmountOutOfRange; - } - 1 => { - return crate::error::PaymentError::InvalidOrExpiredFees; - } - 2 => { - return crate::error::PaymentError::InsufficientFunds; - } - 3 => { return crate::error::PaymentError::AlreadyClaimed; } + 1 => { + return crate::error::PaymentError::AmountOutOfRange; + } + 2 => { + let mut var_err = ::sse_decode(deserializer); + return crate::error::PaymentError::Generic { err: var_err }; + } + 3 => { + return crate::error::PaymentError::InvalidOrExpiredFees; + } 4 => { + return crate::error::PaymentError::InsufficientFunds; + } + 5 => { + return crate::error::PaymentError::InvalidInvoice; + } + 6 => { + return crate::error::PaymentError::InvalidPreimage; + } + 7 => { + let mut var_err = ::sse_decode(deserializer); + return crate::error::PaymentError::LwkError { err: var_err }; + } + 8 => { + return crate::error::PaymentError::PairsNotFound; + } + 9 => { + return crate::error::PaymentError::PersistError; + } + 10 => { let mut var_err = ::sse_decode(deserializer); let mut var_txid = ::sse_decode(deserializer); return crate::error::PaymentError::Refunded { @@ -435,26 +455,6 @@ impl SseDecode for crate::error::PaymentError { txid: var_txid, }; } - 5 => { - let mut var_err = ::sse_decode(deserializer); - return crate::error::PaymentError::Generic { err: var_err }; - } - 6 => { - return crate::error::PaymentError::InvalidInvoice; - } - 7 => { - return crate::error::PaymentError::InvalidPreimage; - } - 8 => { - let mut var_err = ::sse_decode(deserializer); - return crate::error::PaymentError::LwkError { err: var_err }; - } - 9 => { - return crate::error::PaymentError::PairsNotFound; - } - 10 => { - return crate::error::PaymentError::PersistError; - } 11 => { let mut var_err = ::sse_decode(deserializer); return crate::error::PaymentError::SendError { err: var_err }; @@ -701,26 +701,26 @@ impl flutter_rust_bridge::IntoIntoDart for crate::model:: impl flutter_rust_bridge::IntoDart for crate::error::PaymentError { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { match self { - crate::error::PaymentError::AmountOutOfRange => [0.into_dart()].into_dart(), - crate::error::PaymentError::InvalidOrExpiredFees => [1.into_dart()].into_dart(), - crate::error::PaymentError::InsufficientFunds => [2.into_dart()].into_dart(), - crate::error::PaymentError::AlreadyClaimed => [3.into_dart()].into_dart(), + crate::error::PaymentError::AlreadyClaimed => [0.into_dart()].into_dart(), + crate::error::PaymentError::AmountOutOfRange => [1.into_dart()].into_dart(), + crate::error::PaymentError::Generic { err } => { + [2.into_dart(), err.into_into_dart().into_dart()].into_dart() + } + crate::error::PaymentError::InvalidOrExpiredFees => [3.into_dart()].into_dart(), + crate::error::PaymentError::InsufficientFunds => [4.into_dart()].into_dart(), + crate::error::PaymentError::InvalidInvoice => [5.into_dart()].into_dart(), + crate::error::PaymentError::InvalidPreimage => [6.into_dart()].into_dart(), + crate::error::PaymentError::LwkError { err } => { + [7.into_dart(), err.into_into_dart().into_dart()].into_dart() + } + crate::error::PaymentError::PairsNotFound => [8.into_dart()].into_dart(), + crate::error::PaymentError::PersistError => [9.into_dart()].into_dart(), crate::error::PaymentError::Refunded { err, txid } => [ - 4.into_dart(), + 10.into_dart(), err.into_into_dart().into_dart(), txid.into_into_dart().into_dart(), ] .into_dart(), - crate::error::PaymentError::Generic { err } => { - [5.into_dart(), err.into_into_dart().into_dart()].into_dart() - } - crate::error::PaymentError::InvalidInvoice => [6.into_dart()].into_dart(), - crate::error::PaymentError::InvalidPreimage => [7.into_dart()].into_dart(), - crate::error::PaymentError::LwkError { err } => { - [8.into_dart(), err.into_into_dart().into_dart()].into_dart() - } - crate::error::PaymentError::PairsNotFound => [9.into_dart()].into_dart(), - crate::error::PaymentError::PersistError => [10.into_dart()].into_dart(), crate::error::PaymentError::SendError { err } => { [11.into_dart(), err.into_into_dart().into_dart()].into_dart() } @@ -1016,42 +1016,42 @@ impl SseEncode for crate::error::PaymentError { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { match self { - crate::error::PaymentError::AmountOutOfRange => { + crate::error::PaymentError::AlreadyClaimed => { ::sse_encode(0, serializer); } - crate::error::PaymentError::InvalidOrExpiredFees => { + crate::error::PaymentError::AmountOutOfRange => { ::sse_encode(1, serializer); } - crate::error::PaymentError::InsufficientFunds => { + crate::error::PaymentError::Generic { err } => { ::sse_encode(2, serializer); + ::sse_encode(err, serializer); } - crate::error::PaymentError::AlreadyClaimed => { + crate::error::PaymentError::InvalidOrExpiredFees => { ::sse_encode(3, serializer); } - crate::error::PaymentError::Refunded { err, txid } => { + crate::error::PaymentError::InsufficientFunds => { ::sse_encode(4, serializer); - ::sse_encode(err, serializer); - ::sse_encode(txid, serializer); - } - crate::error::PaymentError::Generic { err } => { - ::sse_encode(5, serializer); - ::sse_encode(err, serializer); } crate::error::PaymentError::InvalidInvoice => { - ::sse_encode(6, serializer); + ::sse_encode(5, serializer); } crate::error::PaymentError::InvalidPreimage => { - ::sse_encode(7, serializer); + ::sse_encode(6, serializer); } crate::error::PaymentError::LwkError { err } => { - ::sse_encode(8, serializer); + ::sse_encode(7, serializer); ::sse_encode(err, serializer); } crate::error::PaymentError::PairsNotFound => { - ::sse_encode(9, serializer); + ::sse_encode(8, serializer); } crate::error::PaymentError::PersistError => { + ::sse_encode(9, serializer); + } + crate::error::PaymentError::Refunded { err, txid } => { ::sse_encode(10, serializer); + ::sse_encode(err, serializer); + ::sse_encode(txid, serializer); } crate::error::PaymentError::SendError { err } => { ::sse_encode(11, serializer); diff --git a/packages/dart/lib/src/bindings.dart b/packages/dart/lib/src/bindings.dart index 1d9e33b..0648bb1 100644 --- a/packages/dart/lib/src/bindings.dart +++ b/packages/dart/lib/src/bindings.dart @@ -29,28 +29,9 @@ Future receivePayment({required PrepareReceiveResponse r Future> listPayments({required bool withScan, required bool includePending, dynamic hint}) => RustLib.instance.api.listPayments(withScan: withScan, includePending: includePending, hint: hint); -Future recoverFunds({required LBtcReverseRecovery recovery, dynamic hint}) => - RustLib.instance.api.recoverFunds(recovery: recovery, hint: hint); - Future emptyWalletCache({dynamic hint}) => RustLib.instance.api.emptyWalletCache(hint: hint); Future backup({dynamic hint}) => RustLib.instance.api.backup(hint: hint); Future restore({required RestoreRequest req, dynamic hint}) => RustLib.instance.api.restore(req: req, hint: hint); - -// Rust type: RustOpaqueNom> -@sealed -class LBtcReverseRecovery extends RustOpaque { - LBtcReverseRecovery.dcoDecode(List wire) : super.dcoDecode(wire, _kStaticData); - - LBtcReverseRecovery.sseDecode(int ptr, int externalSizeOnNative) - : super.sseDecode(ptr, externalSizeOnNative, _kStaticData); - - static final _kStaticData = RustArcStaticData( - rustArcIncrementStrongCount: RustLib.instance.api.rust_arc_increment_strong_count_LBtcReverseRecovery, - rustArcDecrementStrongCount: RustLib.instance.api.rust_arc_decrement_strong_count_LBtcReverseRecovery, - rustArcDecrementStrongCountPtr: - RustLib.instance.api.rust_arc_decrement_strong_count_LBtcReverseRecoveryPtr, - ); -} diff --git a/packages/dart/lib/src/error.dart b/packages/dart/lib/src/error.dart index 31537c4..7649c98 100644 --- a/packages/dart/lib/src/error.dart +++ b/packages/dart/lib/src/error.dart @@ -12,19 +12,13 @@ part 'error.freezed.dart'; sealed class PaymentError with _$PaymentError implements FrbException { const PaymentError._(); - const factory PaymentError.amountOutOfRange() = PaymentError_AmountOutOfRange; - const factory PaymentError.invalidOrExpiredFees() = - PaymentError_InvalidOrExpiredFees; - const factory PaymentError.insufficientFunds() = - PaymentError_InsufficientFunds; const factory PaymentError.alreadyClaimed() = PaymentError_AlreadyClaimed; - const factory PaymentError.refunded({ - required String err, - required String txid, - }) = PaymentError_Refunded; + const factory PaymentError.amountOutOfRange() = PaymentError_AmountOutOfRange; const factory PaymentError.generic({ required String err, }) = PaymentError_Generic; + const factory PaymentError.invalidOrExpiredFees() = PaymentError_InvalidOrExpiredFees; + const factory PaymentError.insufficientFunds() = PaymentError_InsufficientFunds; const factory PaymentError.invalidInvoice() = PaymentError_InvalidInvoice; const factory PaymentError.invalidPreimage() = PaymentError_InvalidPreimage; const factory PaymentError.lwkError({ @@ -32,6 +26,10 @@ sealed class PaymentError with _$PaymentError implements FrbException { }) = PaymentError_LwkError; const factory PaymentError.pairsNotFound() = PaymentError_PairsNotFound; const factory PaymentError.persistError() = PaymentError_PersistError; + const factory PaymentError.refunded({ + required String err, + required String txid, + }) = PaymentError_Refunded; const factory PaymentError.sendError({ required String err, }) = PaymentError_SendError; diff --git a/packages/dart/lib/src/error.freezed.dart b/packages/dart/lib/src/error.freezed.dart index ff5179d..95f81a5 100644 --- a/packages/dart/lib/src/error.freezed.dart +++ b/packages/dart/lib/src/error.freezed.dart @@ -33,141 +33,6 @@ class _$PaymentErrorCopyWithImpl<$Res, $Val extends PaymentError> implements $Pa final $Res Function($Val) _then; } -/// @nodoc -abstract class _$$PaymentError_AmountOutOfRangeImplCopyWith<$Res> { - factory _$$PaymentError_AmountOutOfRangeImplCopyWith(_$PaymentError_AmountOutOfRangeImpl value, - $Res Function(_$PaymentError_AmountOutOfRangeImpl) then) = - __$$PaymentError_AmountOutOfRangeImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$PaymentError_AmountOutOfRangeImplCopyWithImpl<$Res> - extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_AmountOutOfRangeImpl> - implements _$$PaymentError_AmountOutOfRangeImplCopyWith<$Res> { - __$$PaymentError_AmountOutOfRangeImplCopyWithImpl( - _$PaymentError_AmountOutOfRangeImpl _value, $Res Function(_$PaymentError_AmountOutOfRangeImpl) _then) - : super(_value, _then); -} - -/// @nodoc - -class _$PaymentError_AmountOutOfRangeImpl extends PaymentError_AmountOutOfRange { - const _$PaymentError_AmountOutOfRangeImpl() : super._(); - - @override - String toString() { - return 'PaymentError.amountOutOfRange()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$PaymentError_AmountOutOfRangeImpl); - } - - @override - int get hashCode => runtimeType.hashCode; -} - -abstract class PaymentError_AmountOutOfRange extends PaymentError { - const factory PaymentError_AmountOutOfRange() = _$PaymentError_AmountOutOfRangeImpl; - const PaymentError_AmountOutOfRange._() : super._(); -} - -/// @nodoc -abstract class _$$PaymentError_InvalidOrExpiredFeesImplCopyWith<$Res> { - factory _$$PaymentError_InvalidOrExpiredFeesImplCopyWith( - _$PaymentError_InvalidOrExpiredFeesImpl value, - $Res Function(_$PaymentError_InvalidOrExpiredFeesImpl) then) = - __$$PaymentError_InvalidOrExpiredFeesImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$PaymentError_InvalidOrExpiredFeesImplCopyWithImpl<$Res> - extends _$PaymentErrorCopyWithImpl<$Res, - _$PaymentError_InvalidOrExpiredFeesImpl> - implements _$$PaymentError_InvalidOrExpiredFeesImplCopyWith<$Res> { - __$$PaymentError_InvalidOrExpiredFeesImplCopyWithImpl( - _$PaymentError_InvalidOrExpiredFeesImpl _value, - $Res Function(_$PaymentError_InvalidOrExpiredFeesImpl) _then) - : super(_value, _then); -} - -/// @nodoc - -class _$PaymentError_InvalidOrExpiredFeesImpl - extends PaymentError_InvalidOrExpiredFees { - const _$PaymentError_InvalidOrExpiredFeesImpl() : super._(); - - @override - String toString() { - return 'PaymentError.invalidOrExpiredFees()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PaymentError_InvalidOrExpiredFeesImpl); - } - - @override - int get hashCode => runtimeType.hashCode; -} - -abstract class PaymentError_InvalidOrExpiredFees extends PaymentError { - const factory PaymentError_InvalidOrExpiredFees() = - _$PaymentError_InvalidOrExpiredFeesImpl; - const PaymentError_InvalidOrExpiredFees._() : super._(); -} - -/// @nodoc -abstract class _$$PaymentError_InsufficientFundsImplCopyWith<$Res> { - factory _$$PaymentError_InsufficientFundsImplCopyWith( - _$PaymentError_InsufficientFundsImpl value, - $Res Function(_$PaymentError_InsufficientFundsImpl) then) = - __$$PaymentError_InsufficientFundsImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$PaymentError_InsufficientFundsImplCopyWithImpl<$Res> - extends _$PaymentErrorCopyWithImpl<$Res, - _$PaymentError_InsufficientFundsImpl> - implements _$$PaymentError_InsufficientFundsImplCopyWith<$Res> { - __$$PaymentError_InsufficientFundsImplCopyWithImpl( - _$PaymentError_InsufficientFundsImpl _value, - $Res Function(_$PaymentError_InsufficientFundsImpl) _then) - : super(_value, _then); -} - -/// @nodoc - -class _$PaymentError_InsufficientFundsImpl - extends PaymentError_InsufficientFunds { - const _$PaymentError_InsufficientFundsImpl() : super._(); - - @override - String toString() { - return 'PaymentError.insufficientFunds()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PaymentError_InsufficientFundsImpl); - } - - @override - int get hashCode => runtimeType.hashCode; -} - -abstract class PaymentError_InsufficientFunds extends PaymentError { - const factory PaymentError_InsufficientFunds() = - _$PaymentError_InsufficientFundsImpl; - const PaymentError_InsufficientFunds._() : super._(); -} - /// @nodoc abstract class _$$PaymentError_AlreadyClaimedImplCopyWith<$Res> { factory _$$PaymentError_AlreadyClaimedImplCopyWith( @@ -210,89 +75,44 @@ abstract class PaymentError_AlreadyClaimed extends PaymentError { } /// @nodoc -abstract class _$$PaymentError_RefundedImplCopyWith<$Res> { - factory _$$PaymentError_RefundedImplCopyWith( - _$PaymentError_RefundedImpl value, - $Res Function(_$PaymentError_RefundedImpl) then) = - __$$PaymentError_RefundedImplCopyWithImpl<$Res>; - @useResult - $Res call({String err, String txid}); +abstract class _$$PaymentError_AmountOutOfRangeImplCopyWith<$Res> { + factory _$$PaymentError_AmountOutOfRangeImplCopyWith(_$PaymentError_AmountOutOfRangeImpl value, + $Res Function(_$PaymentError_AmountOutOfRangeImpl) then) = + __$$PaymentError_AmountOutOfRangeImplCopyWithImpl<$Res>; } /// @nodoc -class __$$PaymentError_RefundedImplCopyWithImpl<$Res> - extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_RefundedImpl> - implements _$$PaymentError_RefundedImplCopyWith<$Res> { - __$$PaymentError_RefundedImplCopyWithImpl(_$PaymentError_RefundedImpl _value, - $Res Function(_$PaymentError_RefundedImpl) _then) +class __$$PaymentError_AmountOutOfRangeImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_AmountOutOfRangeImpl> + implements _$$PaymentError_AmountOutOfRangeImplCopyWith<$Res> { + __$$PaymentError_AmountOutOfRangeImplCopyWithImpl( + _$PaymentError_AmountOutOfRangeImpl _value, $Res Function(_$PaymentError_AmountOutOfRangeImpl) _then) : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? err = null, - Object? txid = null, - }) { - return _then(_$PaymentError_RefundedImpl( - err: null == err - ? _value.err - : err // ignore: cast_nullable_to_non_nullable - as String, - txid: null == txid - ? _value.txid - : txid // ignore: cast_nullable_to_non_nullable - as String, - )); - } } /// @nodoc -class _$PaymentError_RefundedImpl extends PaymentError_Refunded { - const _$PaymentError_RefundedImpl({required this.err, required this.txid}) - : super._(); - - @override - final String err; - @override - final String txid; +class _$PaymentError_AmountOutOfRangeImpl extends PaymentError_AmountOutOfRange { + const _$PaymentError_AmountOutOfRangeImpl() : super._(); @override String toString() { - return 'PaymentError.refunded(err: $err, txid: $txid)'; + return 'PaymentError.amountOutOfRange()'; } @override bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PaymentError_RefundedImpl && - (identical(other.err, err) || other.err == err) && - (identical(other.txid, txid) || other.txid == txid)); + (other.runtimeType == runtimeType && other is _$PaymentError_AmountOutOfRangeImpl); } @override - int get hashCode => Object.hash(runtimeType, err, txid); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$PaymentError_RefundedImplCopyWith<_$PaymentError_RefundedImpl> - get copyWith => __$$PaymentError_RefundedImplCopyWithImpl< - _$PaymentError_RefundedImpl>(this, _$identity); + int get hashCode => runtimeType.hashCode; } -abstract class PaymentError_Refunded extends PaymentError { - const factory PaymentError_Refunded( - {required final String err, - required final String txid}) = _$PaymentError_RefundedImpl; - const PaymentError_Refunded._() : super._(); - - String get err; - String get txid; - @JsonKey(ignore: true) - _$$PaymentError_RefundedImplCopyWith<_$PaymentError_RefundedImpl> - get copyWith => throw _privateConstructorUsedError; +abstract class PaymentError_AmountOutOfRange extends PaymentError { + const factory PaymentError_AmountOutOfRange() = _$PaymentError_AmountOutOfRangeImpl; + const PaymentError_AmountOutOfRange._() : super._(); } /// @nodoc @@ -367,6 +187,88 @@ abstract class PaymentError_Generic extends PaymentError { throw _privateConstructorUsedError; } +/// @nodoc +abstract class _$$PaymentError_InvalidOrExpiredFeesImplCopyWith<$Res> { + factory _$$PaymentError_InvalidOrExpiredFeesImplCopyWith(_$PaymentError_InvalidOrExpiredFeesImpl value, + $Res Function(_$PaymentError_InvalidOrExpiredFeesImpl) then) = + __$$PaymentError_InvalidOrExpiredFeesImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_InvalidOrExpiredFeesImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_InvalidOrExpiredFeesImpl> + implements _$$PaymentError_InvalidOrExpiredFeesImplCopyWith<$Res> { + __$$PaymentError_InvalidOrExpiredFeesImplCopyWithImpl(_$PaymentError_InvalidOrExpiredFeesImpl _value, + $Res Function(_$PaymentError_InvalidOrExpiredFeesImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_InvalidOrExpiredFeesImpl extends PaymentError_InvalidOrExpiredFees { + const _$PaymentError_InvalidOrExpiredFeesImpl() : super._(); + + @override + String toString() { + return 'PaymentError.invalidOrExpiredFees()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$PaymentError_InvalidOrExpiredFeesImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_InvalidOrExpiredFees extends PaymentError { + const factory PaymentError_InvalidOrExpiredFees() = _$PaymentError_InvalidOrExpiredFeesImpl; + const PaymentError_InvalidOrExpiredFees._() : super._(); +} + +/// @nodoc +abstract class _$$PaymentError_InsufficientFundsImplCopyWith<$Res> { + factory _$$PaymentError_InsufficientFundsImplCopyWith(_$PaymentError_InsufficientFundsImpl value, + $Res Function(_$PaymentError_InsufficientFundsImpl) then) = + __$$PaymentError_InsufficientFundsImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_InsufficientFundsImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_InsufficientFundsImpl> + implements _$$PaymentError_InsufficientFundsImplCopyWith<$Res> { + __$$PaymentError_InsufficientFundsImplCopyWithImpl( + _$PaymentError_InsufficientFundsImpl _value, $Res Function(_$PaymentError_InsufficientFundsImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_InsufficientFundsImpl extends PaymentError_InsufficientFunds { + const _$PaymentError_InsufficientFundsImpl() : super._(); + + @override + String toString() { + return 'PaymentError.insufficientFunds()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$PaymentError_InsufficientFundsImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_InsufficientFunds extends PaymentError { + const factory PaymentError_InsufficientFunds() = _$PaymentError_InsufficientFundsImpl; + const PaymentError_InsufficientFunds._() : super._(); +} + /// @nodoc abstract class _$$PaymentError_InvalidInvoiceImplCopyWith<$Res> { factory _$$PaymentError_InvalidInvoiceImplCopyWith( @@ -603,6 +505,88 @@ abstract class PaymentError_PersistError extends PaymentError { const PaymentError_PersistError._() : super._(); } +/// @nodoc +abstract class _$$PaymentError_RefundedImplCopyWith<$Res> { + factory _$$PaymentError_RefundedImplCopyWith( + _$PaymentError_RefundedImpl value, $Res Function(_$PaymentError_RefundedImpl) then) = + __$$PaymentError_RefundedImplCopyWithImpl<$Res>; + @useResult + $Res call({String err, String txid}); +} + +/// @nodoc +class __$$PaymentError_RefundedImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_RefundedImpl> + implements _$$PaymentError_RefundedImplCopyWith<$Res> { + __$$PaymentError_RefundedImplCopyWithImpl( + _$PaymentError_RefundedImpl _value, $Res Function(_$PaymentError_RefundedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? err = null, + Object? txid = null, + }) { + return _then(_$PaymentError_RefundedImpl( + err: null == err + ? _value.err + : err // ignore: cast_nullable_to_non_nullable + as String, + txid: null == txid + ? _value.txid + : txid // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PaymentError_RefundedImpl extends PaymentError_Refunded { + const _$PaymentError_RefundedImpl({required this.err, required this.txid}) : super._(); + + @override + final String err; + @override + final String txid; + + @override + String toString() { + return 'PaymentError.refunded(err: $err, txid: $txid)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_RefundedImpl && + (identical(other.err, err) || other.err == err) && + (identical(other.txid, txid) || other.txid == txid)); + } + + @override + int get hashCode => Object.hash(runtimeType, err, txid); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PaymentError_RefundedImplCopyWith<_$PaymentError_RefundedImpl> get copyWith => + __$$PaymentError_RefundedImplCopyWithImpl<_$PaymentError_RefundedImpl>(this, _$identity); +} + +abstract class PaymentError_Refunded extends PaymentError { + const factory PaymentError_Refunded({required final String err, required final String txid}) = + _$PaymentError_RefundedImpl; + const PaymentError_Refunded._() : super._(); + + String get err; + String get txid; + @JsonKey(ignore: true) + _$$PaymentError_RefundedImplCopyWith<_$PaymentError_RefundedImpl> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc abstract class _$$PaymentError_SendErrorImplCopyWith<$Res> { factory _$$PaymentError_SendErrorImplCopyWith( diff --git a/packages/dart/lib/src/frb_generated.dart b/packages/dart/lib/src/frb_generated.dart index a1773a6..08158dd 100644 --- a/packages/dart/lib/src/frb_generated.dart +++ b/packages/dart/lib/src/frb_generated.dart @@ -53,7 +53,7 @@ class RustLib extends BaseEntrypoint { String get codegenVersion => '2.0.0-dev.33'; @override - int get rustContentHash => -1225779344; + int get rustContentHash => -451265040; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( stem: 'breez_liquid_sdk', @@ -79,17 +79,9 @@ abstract class RustLibApi extends BaseApi { Future receivePayment({required PrepareReceiveResponse req, dynamic hint}); - Future recoverFunds({required LBtcReverseRecovery recovery, dynamic hint}); - Future restore({required RestoreRequest req, dynamic hint}); Future sendPayment({required PrepareSendResponse req, dynamic hint}); - - RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_LBtcReverseRecovery; - - RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_LBtcReverseRecovery; - - CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_LBtcReverseRecoveryPtr; } class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @@ -283,31 +275,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: ["req"], ); - @override - Future recoverFunds({required LBtcReverseRecovery recovery, dynamic hint}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = - cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - recovery); - return wire.wire_recover_funds(port_, arg0); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_String, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kRecoverFundsConstMeta, - argValues: [recovery], - apiImpl: this, - hint: hint, - )); - } - - TaskConstMeta get kRecoverFundsConstMeta => const TaskConstMeta( - debugName: "recover_funds", - argNames: ["recovery"], - ); - @override Future restore({required RestoreRequest req, dynamic hint}) { return handler.executeNormal(NormalTask( @@ -354,34 +321,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: ["req"], ); - RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_LBtcReverseRecovery => wire - .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery; - - RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_LBtcReverseRecovery => wire - .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery; - @protected AnyhowException dco_decode_AnyhowException(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs return AnyhowException(raw as String); } - @protected - LBtcReverseRecovery - dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return LBtcReverseRecovery.dcoDecode(raw as List); - } - - @protected - LBtcReverseRecovery - dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return LBtcReverseRecovery.dcoDecode(raw as List); - } - @protected String dco_decode_String(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -543,30 +488,39 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { // Codec=Dco (DartCObject based), see doc to use other codecs switch (raw[0]) { case 0: - return PaymentError_AmountOutOfRange(); - case 1: return PaymentError_AlreadyClaimed(); + case 1: + return PaymentError_AmountOutOfRange(); case 2: return PaymentError_Generic( err: dco_decode_String(raw[1]), ); case 3: - return PaymentError_InvalidInvoice(); + return PaymentError_InvalidOrExpiredFees(); case 4: - return PaymentError_InvalidPreimage(); + return PaymentError_InsufficientFunds(); case 5: + return PaymentError_InvalidInvoice(); + case 6: + return PaymentError_InvalidPreimage(); + case 7: return PaymentError_LwkError( err: dco_decode_String(raw[1]), ); - case 6: - return PaymentError_PairsNotFound(); - case 7: - return PaymentError_PersistError(); case 8: + return PaymentError_PairsNotFound(); + case 9: + return PaymentError_PersistError(); + case 10: + return PaymentError_Refunded( + err: dco_decode_String(raw[1]), + txid: dco_decode_String(raw[2]), + ); + case 11: return PaymentError_SendError( err: dco_decode_String(raw[1]), ); - case 9: + case 12: return PaymentError_SignerError( err: dco_decode_String(raw[1]), ); @@ -595,11 +549,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { PrepareReceiveResponse dco_decode_prepare_receive_response(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs final arr = raw as List; - if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return PrepareReceiveResponse( - pairHash: dco_decode_String(arr[0]), - payerAmountSat: dco_decode_u_64(arr[1]), - feesSat: dco_decode_u_64(arr[2]), + payerAmountSat: dco_decode_u_64(arr[0]), + feesSat: dco_decode_u_64(arr[1]), ); } @@ -617,14 +570,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { PrepareSendResponse dco_decode_prepare_send_response(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs final arr = raw as List; - if (arr.length != 6) throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return PrepareSendResponse( - id: dco_decode_String(arr[0]), - payerAmountSat: dco_decode_u_64(arr[1]), - receiverAmountSat: dco_decode_u_64(arr[2]), - totalFees: dco_decode_u_64(arr[3]), - fundingAddress: dco_decode_String(arr[4]), - invoice: dco_decode_String(arr[5]), + invoice: dco_decode_String(arr[0]), + feesSat: dco_decode_u_64(arr[1]), ); } @@ -683,12 +632,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return; } - @protected - int dco_decode_usize(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return dcoDecodeI64OrU64(raw); - } - @protected AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -696,22 +639,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return AnyhowException(inner); } - @protected - LBtcReverseRecovery - sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return LBtcReverseRecovery.sseDecode(sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); - } - - @protected - LBtcReverseRecovery - sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return LBtcReverseRecovery.sseDecode(sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); - } - @protected String sse_decode_String(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -893,27 +820,35 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { var tag_ = sse_decode_i_32(deserializer); switch (tag_) { case 0: - return PaymentError_AmountOutOfRange(); - case 1: return PaymentError_AlreadyClaimed(); + case 1: + return PaymentError_AmountOutOfRange(); case 2: var var_err = sse_decode_String(deserializer); return PaymentError_Generic(err: var_err); case 3: - return PaymentError_InvalidInvoice(); + return PaymentError_InvalidOrExpiredFees(); case 4: - return PaymentError_InvalidPreimage(); + return PaymentError_InsufficientFunds(); case 5: + return PaymentError_InvalidInvoice(); + case 6: + return PaymentError_InvalidPreimage(); + case 7: var var_err = sse_decode_String(deserializer); return PaymentError_LwkError(err: var_err); - case 6: - return PaymentError_PairsNotFound(); - case 7: - return PaymentError_PersistError(); case 8: + return PaymentError_PairsNotFound(); + case 9: + return PaymentError_PersistError(); + case 10: + var var_err = sse_decode_String(deserializer); + var var_txid = sse_decode_String(deserializer); + return PaymentError_Refunded(err: var_err, txid: var_txid); + case 11: var var_err = sse_decode_String(deserializer); return PaymentError_SendError(err: var_err); - case 9: + case 12: var var_err = sse_decode_String(deserializer); return PaymentError_SignerError(err: var_err); default: @@ -938,11 +873,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @protected PrepareReceiveResponse sse_decode_prepare_receive_response(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs - var var_pairHash = sse_decode_String(deserializer); var var_payerAmountSat = sse_decode_u_64(deserializer); var var_feesSat = sse_decode_u_64(deserializer); - return PrepareReceiveResponse( - pairHash: var_pairHash, payerAmountSat: var_payerAmountSat, feesSat: var_feesSat); + return PrepareReceiveResponse(payerAmountSat: var_payerAmountSat, feesSat: var_feesSat); } @protected @@ -955,19 +888,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @protected PrepareSendResponse sse_decode_prepare_send_response(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs - var var_id = sse_decode_String(deserializer); - var var_payerAmountSat = sse_decode_u_64(deserializer); - var var_receiverAmountSat = sse_decode_u_64(deserializer); - var var_totalFees = sse_decode_u_64(deserializer); - var var_fundingAddress = sse_decode_String(deserializer); var var_invoice = sse_decode_String(deserializer); - return PrepareSendResponse( - id: var_id, - payerAmountSat: var_payerAmountSat, - receiverAmountSat: var_receiverAmountSat, - totalFees: var_totalFees, - fundingAddress: var_fundingAddress, - invoice: var_invoice); + var var_feesSat = sse_decode_u_64(deserializer); + return PrepareSendResponse(invoice: var_invoice, feesSat: var_feesSat); } @protected @@ -1015,28 +938,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { // Codec=Sse (Serialization based), see doc to use other codecs } - @protected - int sse_decode_usize(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return deserializer.buffer.getUint64(); - } - - @protected - int cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery raw) { - // Codec=Cst (C-struct based), see doc to use other codecs -// ignore: invalid_use_of_internal_member - return raw.cstEncode(move: true); - } - - @protected - int cst_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery raw) { - // Codec=Cst (C-struct based), see doc to use other codecs -// ignore: invalid_use_of_internal_member - return raw.cstEncode(); - } - @protected bool cst_encode_bool(bool raw) { // Codec=Cst (C-struct based), see doc to use other codecs @@ -1079,33 +980,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw; } - @protected - int cst_encode_usize(int raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - return raw; - } - @protected void sse_encode_AnyhowException(AnyhowException self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs throw UnimplementedError('Unreachable ()'); } - @protected - void - sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_usize(self.sseEncode(move: true), serializer); - } - - @protected - void sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_usize(self.sseEncode(move: null), serializer); - } - @protected void sse_encode_String(String self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -1267,29 +1147,37 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { void sse_encode_payment_error(PaymentError self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs switch (self) { - case PaymentError_AmountOutOfRange(): - sse_encode_i_32(0, serializer); case PaymentError_AlreadyClaimed(): + sse_encode_i_32(0, serializer); + case PaymentError_AmountOutOfRange(): sse_encode_i_32(1, serializer); case PaymentError_Generic(err: final err): sse_encode_i_32(2, serializer); sse_encode_String(err, serializer); - case PaymentError_InvalidInvoice(): + case PaymentError_InvalidOrExpiredFees(): sse_encode_i_32(3, serializer); - case PaymentError_InvalidPreimage(): + case PaymentError_InsufficientFunds(): sse_encode_i_32(4, serializer); - case PaymentError_LwkError(err: final err): + case PaymentError_InvalidInvoice(): sse_encode_i_32(5, serializer); + case PaymentError_InvalidPreimage(): + sse_encode_i_32(6, serializer); + case PaymentError_LwkError(err: final err): + sse_encode_i_32(7, serializer); sse_encode_String(err, serializer); case PaymentError_PairsNotFound(): - sse_encode_i_32(6, serializer); - case PaymentError_PersistError(): - sse_encode_i_32(7, serializer); - case PaymentError_SendError(err: final err): sse_encode_i_32(8, serializer); + case PaymentError_PersistError(): + sse_encode_i_32(9, serializer); + case PaymentError_Refunded(err: final err, txid: final txid): + sse_encode_i_32(10, serializer); + sse_encode_String(err, serializer); + sse_encode_String(txid, serializer); + case PaymentError_SendError(err: final err): + sse_encode_i_32(11, serializer); sse_encode_String(err, serializer); case PaymentError_SignerError(err: final err): - sse_encode_i_32(9, serializer); + sse_encode_i_32(12, serializer); sse_encode_String(err, serializer); } } @@ -1309,7 +1197,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @protected void sse_encode_prepare_receive_response(PrepareReceiveResponse self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_String(self.pairHash, serializer); sse_encode_u_64(self.payerAmountSat, serializer); sse_encode_u_64(self.feesSat, serializer); } @@ -1323,12 +1210,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @protected void sse_encode_prepare_send_response(PrepareSendResponse self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_String(self.id, serializer); - sse_encode_u_64(self.payerAmountSat, serializer); - sse_encode_u_64(self.receiverAmountSat, serializer); - sse_encode_u_64(self.totalFees, serializer); - sse_encode_String(self.fundingAddress, serializer); sse_encode_String(self.invoice, serializer); + sse_encode_u_64(self.feesSat, serializer); } @protected @@ -1372,10 +1255,4 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { void sse_encode_unit(void self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs } - - @protected - void sse_encode_usize(int self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - serializer.buffer.putUint64(self); - } } diff --git a/packages/dart/lib/src/frb_generated.io.dart b/packages/dart/lib/src/frb_generated.io.dart index 4e7eef8..4dfa98e 100644 --- a/packages/dart/lib/src/frb_generated.io.dart +++ b/packages/dart/lib/src/frb_generated.io.dart @@ -20,22 +20,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { required super.portManager, }); - CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_LBtcReverseRecoveryPtr => wire - ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecoveryPtr; - @protected AnyhowException dco_decode_AnyhowException(dynamic raw); - @protected - LBtcReverseRecovery - dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - dynamic raw); - - @protected - LBtcReverseRecovery - dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - dynamic raw); - @protected String dco_decode_String(dynamic raw); @@ -141,22 +128,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void dco_decode_unit(dynamic raw); - @protected - int dco_decode_usize(dynamic raw); - @protected AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); - @protected - LBtcReverseRecovery - sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - SseDeserializer deserializer); - - @protected - LBtcReverseRecovery - sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - SseDeserializer deserializer); - @protected String sse_decode_String(SseDeserializer deserializer); @@ -262,9 +236,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_decode_unit(SseDeserializer deserializer); - @protected - int sse_decode_usize(SseDeserializer deserializer); - @protected ffi.Pointer cst_encode_AnyhowException(AnyhowException raw) { // Codec=Cst (C-struct based), see doc to use other codecs @@ -463,11 +434,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void cst_api_fill_to_wire_payment_error(PaymentError apiObj, wire_cst_payment_error wireObj) { - if (apiObj is PaymentError_AmountOutOfRange) { + if (apiObj is PaymentError_AlreadyClaimed) { wireObj.tag = 0; return; } - if (apiObj is PaymentError_AlreadyClaimed) { + if (apiObj is PaymentError_AmountOutOfRange) { wireObj.tag = 1; return; } @@ -477,37 +448,53 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { wireObj.kind.Generic.err = pre_err; return; } - if (apiObj is PaymentError_InvalidInvoice) { + if (apiObj is PaymentError_InvalidOrExpiredFees) { wireObj.tag = 3; return; } - if (apiObj is PaymentError_InvalidPreimage) { + if (apiObj is PaymentError_InsufficientFunds) { wireObj.tag = 4; return; } + if (apiObj is PaymentError_InvalidInvoice) { + wireObj.tag = 5; + return; + } + if (apiObj is PaymentError_InvalidPreimage) { + wireObj.tag = 6; + return; + } if (apiObj is PaymentError_LwkError) { var pre_err = cst_encode_String(apiObj.err); - wireObj.tag = 5; + wireObj.tag = 7; wireObj.kind.LwkError.err = pre_err; return; } if (apiObj is PaymentError_PairsNotFound) { - wireObj.tag = 6; + wireObj.tag = 8; return; } if (apiObj is PaymentError_PersistError) { - wireObj.tag = 7; + wireObj.tag = 9; + return; + } + if (apiObj is PaymentError_Refunded) { + var pre_err = cst_encode_String(apiObj.err); + var pre_txid = cst_encode_String(apiObj.txid); + wireObj.tag = 10; + wireObj.kind.Refunded.err = pre_err; + wireObj.kind.Refunded.txid = pre_txid; return; } if (apiObj is PaymentError_SendError) { var pre_err = cst_encode_String(apiObj.err); - wireObj.tag = 8; + wireObj.tag = 11; wireObj.kind.SendError.err = pre_err; return; } if (apiObj is PaymentError_SignerError) { var pre_err = cst_encode_String(apiObj.err); - wireObj.tag = 9; + wireObj.tag = 12; wireObj.kind.SignerError.err = pre_err; return; } @@ -522,7 +509,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void cst_api_fill_to_wire_prepare_receive_response( PrepareReceiveResponse apiObj, wire_cst_prepare_receive_response wireObj) { - wireObj.pair_hash = cst_encode_String(apiObj.pairHash); wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat); wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat); } @@ -536,12 +522,8 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void cst_api_fill_to_wire_prepare_send_response( PrepareSendResponse apiObj, wire_cst_prepare_send_response wireObj) { - wireObj.id = cst_encode_String(apiObj.id); - wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat); - wireObj.receiver_amount_sat = cst_encode_u_64(apiObj.receiverAmountSat); - wireObj.total_fees = cst_encode_u_64(apiObj.totalFees); - wireObj.funding_address = cst_encode_String(apiObj.fundingAddress); wireObj.invoice = cst_encode_String(apiObj.invoice); + wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat); } @protected @@ -562,14 +544,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { wireObj.txid = cst_encode_String(apiObj.txid); } - @protected - int cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery raw); - - @protected - int cst_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery raw); - @protected bool cst_encode_bool(bool raw); @@ -591,21 +565,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void cst_encode_unit(void raw); - @protected - int cst_encode_usize(int raw); - @protected void sse_encode_AnyhowException(AnyhowException self, SseSerializer serializer); - @protected - void - sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery self, SseSerializer serializer); - - @protected - void sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - LBtcReverseRecovery self, SseSerializer serializer); - @protected void sse_encode_String(String self, SseSerializer serializer); @@ -710,9 +672,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_encode_unit(void self, SseSerializer serializer); - - @protected - void sse_encode_usize(int self, SseSerializer serializer); } // Section: wire_class @@ -871,20 +830,6 @@ class RustLibWire implements BaseWire { late final _wire_receive_payment = _wire_receive_paymentPtr .asFunction)>(); - void wire_recover_funds( - int port_, - int recovery, - ) { - return _wire_recover_funds( - port_, - recovery, - ); - } - - late final _wire_recover_fundsPtr = _lookup>( - 'frbgen_breez_liquid_wire_recover_funds'); - late final _wire_recover_funds = _wire_recover_fundsPtr.asFunction(); - void wire_restore( int port_, ffi.Pointer req, @@ -917,38 +862,6 @@ class RustLibWire implements BaseWire { late final _wire_send_payment = _wire_send_paymentPtr.asFunction)>(); - void - rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - ffi.Pointer ptr, - ) { - return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - ptr, - ); - } - - late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecoveryPtr = - _lookup)>>( - 'frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery'); - late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery = - _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecoveryPtr - .asFunction)>(); - - void - rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - ffi.Pointer ptr, - ) { - return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery( - ptr, - ); - } - - late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecoveryPtr = - _lookup)>>( - 'frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery'); - late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecovery = - _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLBtcReverseRecoveryPtr - .asFunction)>(); - ffi.Pointer cst_new_box_autoadd_connect_request() { return _cst_new_box_autoadd_connect_request(); } @@ -1123,8 +1036,6 @@ final class wire_cst_prepare_send_request extends ffi.Struct { } final class wire_cst_prepare_receive_response extends ffi.Struct { - external ffi.Pointer pair_hash; - @ffi.Uint64() external int payer_amount_sat; @@ -1137,20 +1048,10 @@ final class wire_cst_restore_request extends ffi.Struct { } final class wire_cst_prepare_send_response extends ffi.Struct { - external ffi.Pointer id; - - @ffi.Uint64() - external int payer_amount_sat; - - @ffi.Uint64() - external int receiver_amount_sat; - - @ffi.Uint64() - external int total_fees; - - external ffi.Pointer funding_address; - external ffi.Pointer invoice; + + @ffi.Uint64() + external int fees_sat; } final class wire_cst_payment extends ffi.Struct { @@ -1191,6 +1092,12 @@ final class wire_cst_PaymentError_LwkError extends ffi.Struct { external ffi.Pointer err; } +final class wire_cst_PaymentError_Refunded extends ffi.Struct { + external ffi.Pointer err; + + external ffi.Pointer txid; +} + final class wire_cst_PaymentError_SendError extends ffi.Struct { external ffi.Pointer err; } @@ -1204,6 +1111,8 @@ final class PaymentErrorKind extends ffi.Union { external wire_cst_PaymentError_LwkError LwkError; + external wire_cst_PaymentError_Refunded Refunded; + external wire_cst_PaymentError_SendError SendError; external wire_cst_PaymentError_SignerError SignerError; @@ -1226,4 +1135,4 @@ final class wire_cst_send_payment_response extends ffi.Struct { external ffi.Pointer txid; } -const double LIQUID_CLAIM_TX_FEERATE = 0.1; +const double LIQUID_CLAIM_TX_FEERATE_MSAT = 100.0; diff --git a/packages/dart/lib/src/model.dart b/packages/dart/lib/src/model.dart index 1dc65fa..169301d 100644 --- a/packages/dart/lib/src/model.dart +++ b/packages/dart/lib/src/model.dart @@ -79,8 +79,6 @@ class Payment { final int amountSat; final int? feesSat; final PaymentType paymentType; - - /// Only for [PaymentType::PendingReceive] final String? invoice; const Payment({ @@ -141,25 +139,22 @@ class PrepareReceiveRequest { } class PrepareReceiveResponse { - final String pairHash; final int payerAmountSat; final int feesSat; const PrepareReceiveResponse({ - required this.pairHash, required this.payerAmountSat, required this.feesSat, }); @override - int get hashCode => pairHash.hashCode ^ payerAmountSat.hashCode ^ feesSat.hashCode; + int get hashCode => payerAmountSat.hashCode ^ feesSat.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is PrepareReceiveResponse && runtimeType == other.runtimeType && - pairHash == other.pairHash && payerAmountSat == other.payerAmountSat && feesSat == other.feesSat; } @@ -181,42 +176,24 @@ class PrepareSendRequest { } class PrepareSendResponse { - final String id; - final int payerAmountSat; - final int receiverAmountSat; - final int totalFees; - final String fundingAddress; final String invoice; + final int feesSat; const PrepareSendResponse({ - required this.id, - required this.payerAmountSat, - required this.receiverAmountSat, - required this.totalFees, - required this.fundingAddress, required this.invoice, + required this.feesSat, }); @override - int get hashCode => - id.hashCode ^ - payerAmountSat.hashCode ^ - receiverAmountSat.hashCode ^ - totalFees.hashCode ^ - fundingAddress.hashCode ^ - invoice.hashCode; + int get hashCode => invoice.hashCode ^ feesSat.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is PrepareSendResponse && runtimeType == other.runtimeType && - id == other.id && - payerAmountSat == other.payerAmountSat && - receiverAmountSat == other.receiverAmountSat && - totalFees == other.totalFees && - fundingAddress == other.fundingAddress && - invoice == other.invoice; + invoice == other.invoice && + feesSat == other.feesSat; } class ReceivePaymentResponse {