Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ enum ErrorCode {
),
unauthorized('UNAUTHORIZED', 'This public key has no wallet connected.'),
internal('INTERNAL', 'An internal error.'),
feeLimitExceeded(
'FEE_LIMIT_EXCEEDED',
'No route fit the max_fee budget and no payment was attempted.',
),
other('OTHER', 'Other error.');

final String value;
Expand Down
3 changes: 2 additions & 1 deletion packages/ndk/lib/domain_layer/usecases/nwc/nwc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,12 @@ class Nwc {
Future<PayInvoiceResponse> payInvoice(
NwcConnection connection, {
required String invoice,
int? maxFeeMsat,
Duration? timeout,
}) async {
return _executeRequest<PayInvoiceResponse>(
connection,
PayInvoiceRequest(invoice: invoice),
PayInvoiceRequest(invoice: invoice, maxFeeMsat: maxFeeMsat),
timeout: timeout,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ import 'nwc_request.dart';
// Subclass for requests to pay a bolt11 invoice
class PayInvoiceRequest extends NwcRequest {
final String invoice;
final int? maxFeeSat;

const PayInvoiceRequest({required this.invoice})
: super(method: NwcMethod.PAY_INVOICE);
const PayInvoiceRequest({required this.invoice, int? maxFeeMsat})
: maxFeeSat = maxFeeMsat == null ? null : maxFeeMsat ~/ 1000,
super(method: NwcMethod.PAY_INVOICE);

@override
Map<String, dynamic> toMap() {
return {
...super.toMap(),
'params': {'invoice': invoice},
'params': {
'invoice': invoice,
if (maxFeeSat != null) 'max_fee': maxFeeSat! * 1000,
},
};
}
}
Loading