dev
dart 48 lines 1016 Bytes
Raw
1 import 'package:cw_core/amount/money.dart';
2 import 'package:cw_core/pending_transaction.dart';
3
4 class PendingLightningTransaction with PendingTransaction {
5 PendingLightningTransaction({
6 required this.id,
7 required this.amount,
8 required this.fee,
9 this.isSendAll = false,
10 required this.commitOverride,
11 });
12
13 final bool isSendAll;
14 Future<String> Function() commitOverride;
15 final List<void Function()> _listeners = [];
16
17 @override
18 String id;
19
20 @override
21 final Money amount;
22
23 @override
24 final Money fee;
25
26 @override
27 String get hex => "";
28
29 @override
30 String get amountFormatted => amount.toString();
31
32 @override
33 int? get outputCount => 1;
34
35 @override
36 Future<void> commit() async {
37 id = await commitOverride.call();
38 _listeners.forEach((e) => e.call());
39 }
40
41 @override
42 bool shouldCommitUR() => false;
43
44 @override
45 Future<Map<String, String>> commitUR() => throw UnimplementedError();
46
47 void addListener(void Function() listener) => _listeners.add(listener);
48 }