Skip to content

Commit

Permalink
timeout on payments 10s
Browse files Browse the repository at this point in the history
  • Loading branch information
frnandu committed Dec 22, 2024
1 parent 3cb8452 commit d596d35
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Zaps {
}
try {
PayInvoiceResponse payResponse =
await _nwc.payInvoice(nwcConnection, invoice: invoice);
await _nwc.payInvoice(nwcConnection, invoice: invoice, timeout: Duration(seconds: 10));
if (payResponse.preimage.isNotEmpty && payResponse.errorCode == null) {
ZapResponse zapResponse = ZapResponse(

Check warning on line 71 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L69-L71

Added lines #L69 - L71 were not covered by tests
payInvoiceResponse: payResponse);
Expand Down Expand Up @@ -114,14 +114,25 @@ class Zaps {
/// fetch all zap receipts matching given pubKey and optional event id, in sats
Future<List<ZapReceipt>> fetchZappedReceipts(

Check warning on line 115 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L115

Added line #L115 was not covered by tests
{required String pubKey, String? eventId, Duration? timeout}) async {
NdkResponse? response = _requests.subscription(filters: [
NdkResponse? response = _requests.query(timeout: timeout??Duration(seconds:10), filters: [

Check warning on line 117 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L117

Added line #L117 was not covered by tests
eventId != null
? Filter(kinds: [ZapReceipt.KIND], eTags: [eventId], pTags: [pubKey])
: Filter(kinds: [ZapReceipt.KIND], pTags: [pubKey])

Check warning on line 120 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L119-L120

Added lines #L119 - L120 were not covered by tests
]);
List<Nip01Event> events = await response.future;
return events.map((event) => ZapReceipt.fromEvent(event)).toList();

Check warning on line 123 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L122-L123

Added lines #L122 - L123 were not covered by tests
}

/// fetch all zap receipts matching given pubKey and optional event id, in sats
NdkResponse subscribeToZapReceipts(

Check warning on line 127 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L127

Added line #L127 was not covered by tests
{required String pubKey, String? eventId}) {
NdkResponse? response = _requests.subscription(filters: [

Check warning on line 129 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L129

Added line #L129 was not covered by tests
eventId != null
? Filter(kinds: [ZapReceipt.KIND], eTags: [eventId], pTags: [pubKey])
: Filter(kinds: [ZapReceipt.KIND], pTags: [pubKey])

Check warning on line 132 in packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart#L131-L132

Added lines #L131 - L132 were not covered by tests
]);
return response;
}
}

/// zap response
Expand Down

0 comments on commit d596d35

Please sign in to comment.