Add magic routing hint support (#265)

* Receive: Add magic routing hint support

* Send: add MRH support

* Filter out and reject self-transfers

* Extract self-transfer validation in own fn

* PrepareSendResponse: use onchain fee as fees_sat if MRH present

* Use onchain tx fee as payment fee, if MRH used for direct onchain tx

* Fix swap fee calculation when MRH is used

* Apply boltz-client patch that aborts send if tx broadcast fails

* Send with MRH: return pending payment

* Receive with MRH: validate BIP21 amount, address

* Emit remaining events for MRH Send, Receive

* Sync: update swap info and emit events after new tx data is persisted

* Extract MRH send into its own send_payment_via_mrh()

* Pending Send via swap: store tx fees for pseudo-tx

* Fix clippy
This commit is contained in:
ok300
2024-06-07 00:40:42 +00:00
committed by GitHub
parent 054b8c6d3b
commit 2928e0fa58
25 changed files with 515 additions and 114 deletions

View File

@@ -833,6 +833,78 @@ abstract class PaymentError_PersistError extends PaymentError {
const PaymentError_PersistError._() : super._();
}
/// @nodoc
abstract class _$$PaymentError_ReceiveErrorImplCopyWith<$Res> {
factory _$$PaymentError_ReceiveErrorImplCopyWith(
_$PaymentError_ReceiveErrorImpl value, $Res Function(_$PaymentError_ReceiveErrorImpl) then) =
__$$PaymentError_ReceiveErrorImplCopyWithImpl<$Res>;
@useResult
$Res call({String err});
}
/// @nodoc
class __$$PaymentError_ReceiveErrorImplCopyWithImpl<$Res>
extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_ReceiveErrorImpl>
implements _$$PaymentError_ReceiveErrorImplCopyWith<$Res> {
__$$PaymentError_ReceiveErrorImplCopyWithImpl(
_$PaymentError_ReceiveErrorImpl _value, $Res Function(_$PaymentError_ReceiveErrorImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? err = null,
}) {
return _then(_$PaymentError_ReceiveErrorImpl(
err: null == err
? _value.err
: err // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$PaymentError_ReceiveErrorImpl extends PaymentError_ReceiveError {
const _$PaymentError_ReceiveErrorImpl({required this.err}) : super._();
@override
final String err;
@override
String toString() {
return 'PaymentError.receiveError(err: $err)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PaymentError_ReceiveErrorImpl &&
(identical(other.err, err) || other.err == err));
}
@override
int get hashCode => Object.hash(runtimeType, err);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$PaymentError_ReceiveErrorImplCopyWith<_$PaymentError_ReceiveErrorImpl> get copyWith =>
__$$PaymentError_ReceiveErrorImplCopyWithImpl<_$PaymentError_ReceiveErrorImpl>(this, _$identity);
}
abstract class PaymentError_ReceiveError extends PaymentError {
const factory PaymentError_ReceiveError({required final String err}) = _$PaymentError_ReceiveErrorImpl;
const PaymentError_ReceiveError._() : super._();
String get err;
@JsonKey(ignore: true)
_$$PaymentError_ReceiveErrorImplCopyWith<_$PaymentError_ReceiveErrorImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$PaymentError_RefundedImplCopyWith<$Res> {
factory _$$PaymentError_RefundedImplCopyWith(
@@ -915,6 +987,49 @@ abstract class PaymentError_Refunded extends PaymentError {
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$PaymentError_SelfTransferNotSupportedImplCopyWith<$Res> {
factory _$$PaymentError_SelfTransferNotSupportedImplCopyWith(
_$PaymentError_SelfTransferNotSupportedImpl value,
$Res Function(_$PaymentError_SelfTransferNotSupportedImpl) then) =
__$$PaymentError_SelfTransferNotSupportedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$PaymentError_SelfTransferNotSupportedImplCopyWithImpl<$Res>
extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_SelfTransferNotSupportedImpl>
implements _$$PaymentError_SelfTransferNotSupportedImplCopyWith<$Res> {
__$$PaymentError_SelfTransferNotSupportedImplCopyWithImpl(
_$PaymentError_SelfTransferNotSupportedImpl _value,
$Res Function(_$PaymentError_SelfTransferNotSupportedImpl) _then)
: super(_value, _then);
}
/// @nodoc
class _$PaymentError_SelfTransferNotSupportedImpl extends PaymentError_SelfTransferNotSupported {
const _$PaymentError_SelfTransferNotSupportedImpl() : super._();
@override
String toString() {
return 'PaymentError.selfTransferNotSupported()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$PaymentError_SelfTransferNotSupportedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
}
abstract class PaymentError_SelfTransferNotSupported extends PaymentError {
const factory PaymentError_SelfTransferNotSupported() = _$PaymentError_SelfTransferNotSupportedImpl;
const PaymentError_SelfTransferNotSupported._() : super._();
}
/// @nodoc
abstract class _$$PaymentError_SendErrorImplCopyWith<$Res> {
factory _$$PaymentError_SendErrorImplCopyWith(