Update `breez_sdk_spark_flutter` to v0.23.0 and adjust pubspec overrides (#3558)
* chore: update `breez_sdk_spark_flutter` to v0.23.0 and update pubspec overrides * feat: use latest breez sdk
Konstantin Ullrich committed
Aug 25, 2026 at 19:29 UTC
bd36227974b550ebb07b2b9e1e8a909e7a59d79b
3 files changed
+73
-55
cw_bitcoin/lib/lightning/lightning_wallet.dart
+71
-53
@@ -17,6 +17,16 @@ bool _breezSdkSparkLibUninitialized = true;
17
Stream<LogEntry>? _logStream;
18
19
class LightningWallet {
20
+ LightningWallet({
21
+ required this.mnemonic,
22
+ required this.apiKey,
23
+ required this.lnurlDomain,
24
+ this.network = Network.mainnet,
25
+ this.passphrase,
26
+ this.seedBytes,
27
+ this.cachedAddress,
28
+ });
29
+
30
final String mnemonic;
31
final String? passphrase;
32
final Uint8List? seedBytes;
@@ -29,16 +39,6 @@ class LightningWallet {
39
40
static int MAX_RETRIES = 10;
41
32
- LightningWallet({
33
- required this.mnemonic,
34
- this.passphrase,
35
- this.seedBytes,
36
- required this.apiKey,
37
- required this.lnurlDomain,
38
- this.network = Network.mainnet,
39
- this.cachedAddress,
40
- });
41
-
42
static bool get isAvailable => Platform.isIOS || Platform.isAndroid || Platform.isMacOS;
43
44
Currency get currency => CryptoCurrency.btcln;
@@ -87,10 +87,11 @@ class LightningWallet {
87
? Seed.entropy(seedBytes!)
88
: Seed.mnemonic(mnemonic: mnemonic, passphrase: passphrase);
89
final config = defaultConfig(network: Network.mainnet).copyWith(
90
- lnurlDomain: lnurlDomain,
91
- apiKey: apiKey,
92
- privateEnabledDefault: true,
93
- maxDepositClaimFee: MaxFee.rate(satPerVbyte: BigInt.from(5)));
90
+ lnurlDomain: lnurlDomain,
91
+ apiKey: apiKey,
92
+ privateEnabledDefault: true,
93
+ maxDepositClaimFee: MaxFee.rate(satPerVbyte: BigInt.from(5)),
94
+ );
95
96
final connectRequest = ConnectRequest(
97
config: config,
@@ -110,7 +111,7 @@ class LightningWallet {
111
printV(e);
112
}
113
113
- await sdk.syncWallet(request: SyncWalletRequest());
114
+ await sdk.syncWallet(request: const SyncWalletRequest());
115
116
return true;
117
} catch (e) {
@@ -139,31 +140,33 @@ class LightningWallet {
140
}
141
} catch (_) {} // No need to log here since it should be in the lightning log
142
retries++;
142
- await Future.delayed(Duration(milliseconds: 500));
143
+ await Future.delayed(const Duration(milliseconds: 500));
144
}
145
146
return cachedAddress;
147
}
148
149
Future<String> getDepositAddress() async => (await sdk.receivePayment(
149
- request: ReceivePaymentRequest(paymentMethod: ReceivePaymentMethod.bitcoinAddress())))
150
- .paymentRequest;
150
+ request: const ReceivePaymentRequest(paymentMethod: ReceivePaymentMethod.bitcoinAddress()),
151
+ ))
152
+ .paymentRequest;
153
154
Future<Money> getBalance() async {
155
try {
154
- return Money((await sdk.getInfo(request: GetInfoRequest(ensureSynced: true))).balanceSats,
155
- CryptoCurrency.btcln);
156
+ return Money(
157
+ (await sdk.getInfo(request: const GetInfoRequest(ensureSynced: true))).balanceSats,
158
+ CryptoCurrency.btcln,
159
+ );
160
} on SdkError_Generic catch (_) {
161
} on SdkError_NetworkError catch (_) {}
162
163
return Money.zero(CryptoCurrency.btcln);
164
}
165
162
- Future<String> registerAddress(String username) async {
163
- return (await sdk.registerLightningAddress(
164
- request: RegisterLightningAddressRequest(username: username)))
165
- .lightningAddress;
166
- }
166
+ Future<String> registerAddress(String username) async => (await sdk.registerLightningAddress(
167
+ request: RegisterLightningAddressRequest(username: username),
168
+ ))
169
+ .lightningAddress;
170
171
Future<String?> getBolt11Invoice(BigInt? amount, String description) async {
172
try {
@@ -180,7 +183,9 @@ class LightningWallet {
183
} on SdkError_NetworkError catch (_) {
184
return null;
185
} on SdkError_SparkError catch (e) {
183
- if (!e.field0.contains("dns") && !e.field0.contains("TimedOut")) rethrow;
186
+ if (!e.field0.contains("dns") && !e.field0.contains("TimedOut")) {
187
+ rethrow;
188
+ }
189
return null;
190
}
191
}
@@ -196,17 +201,22 @@ class LightningWallet {
201
}
202
}
203
199
- Future<PendingLightningTransaction> createTransaction(String address, BigInt? amountSats,
200
- BitcoinTransactionPriority? priority, bool feesIncluded) async {
204
+ Future<PendingLightningTransaction> createTransaction(
205
+ String address,
206
+ BigInt? amountSats,
207
+ BitcoinTransactionPriority? priority,
208
+ bool feesIncluded,
209
+ ) async {
210
final inputType = await sdk.parse(input: address);
211
212
final feePolicy = feesIncluded ? FeePolicy.feesIncluded : FeePolicy.feesExcluded;
213
214
if (inputType is InputType_Bolt11Invoice) {
215
final request = PrepareSendPaymentRequest(
207
- paymentRequest: inputType.field0.invoice.bolt11,
208
- amount: amountSats,
209
- feePolicy: feePolicy);
216
+ paymentRequest: PaymentRequest.input(input: inputType.field0.invoice.bolt11),
217
+ amount: amountSats,
218
+ feePolicy: feePolicy,
219
+ );
220
final prepareResponse = await sdk.prepareSendPayment(request: request);
221
222
final paymentMethod = prepareResponse.paymentMethod;
@@ -227,7 +237,8 @@ class LightningWallet {
237
commitOverride: () async {
238
try {
239
final res = await sdk.sendPayment(
230
- request: SendPaymentRequest(prepareResponse: prepareResponse));
240
+ request: SendPaymentRequest(prepareResponse: prepareResponse),
241
+ );
242
printV(res.payment.status.name);
243
return res.payment.id;
244
} on SdkError_SparkError catch (e) {
@@ -240,7 +251,7 @@ class LightningWallet {
251
);
252
}
253
} else if (inputType is InputType_LightningAddress || inputType is InputType_LnurlPay) {
243
- final optionalValidateSuccessActionUrl = true;
254
+ const optionalValidateSuccessActionUrl = true;
255
256
PrepareLnurlPayRequest request;
257
if (inputType is InputType_LightningAddress) {
@@ -274,7 +285,7 @@ class LightningWallet {
285
);
286
} else if (inputType is InputType_BitcoinAddress) {
287
final request = PrepareSendPaymentRequest(
277
- paymentRequest: inputType.field0.address,
288
+ paymentRequest: PaymentRequest.input(input: inputType.field0.address),
289
amount: amountSats,
290
feePolicy: feePolicy,
291
);
@@ -309,7 +320,8 @@ class LightningWallet {
320
final options =
321
SendPaymentOptions.bitcoinAddress(confirmationSpeed: onchainConfirmationSpeed);
322
final res = await sdk.sendPayment(
312
- request: SendPaymentRequest(prepareResponse: prepareResponse, options: options));
323
+ request: SendPaymentRequest(prepareResponse: prepareResponse, options: options),
324
+ );
325
return res.payment.id;
326
},
327
);
@@ -326,7 +338,7 @@ class LightningWallet {
338
// statusFilter: [PaymentStatus.completed],
339
fromTimestamp:
340
fromDate != null ? BigInt.from((fromDate.millisecondsSinceEpoch / 1000).round()) : null,
329
- assetFilter: AssetFilter.bitcoin(),
341
+ assetFilter: const AssetFilter.bitcoin(),
342
offset: 0,
343
limit: 50,
344
sortAscending: false, // Sort order (true = oldest first, false = newest first)
@@ -357,7 +369,7 @@ class LightningWallet {
369
///
370
Future<List<Map<String, dynamic>>> getUnclaimedDeposits() async {
371
final unclaimedDeposits = <Map<String, dynamic>>[];
360
- final response = await sdk.listUnclaimedDeposits(request: ListUnclaimedDepositsRequest());
372
+ final response = await sdk.listUnclaimedDeposits(request: const ListUnclaimedDepositsRequest());
373
for (final deposit in response.deposits) {
374
final unclaimedDeposit = {
375
"txId": deposit.txid,
@@ -380,7 +392,7 @@ class LightningWallet {
392
return unclaimedDeposits;
393
}
394
383
- Future<ElectrumTransactionInfo> claimDeposit(String txId, int vout, BigInt newFee) async {
395
+ Future<ElectrumTransactionInfo?> claimDeposit(String txId, int vout, BigInt newFee) async {
396
final response = await sdk.claimDeposit(
397
request: ClaimDepositRequest(
398
txid: txId,
@@ -389,11 +401,18 @@ class LightningWallet {
401
),
402
);
403
392
- return _getElectrumTransactionInfoFromPayment(response.payment);
404
+ if (response.payment == null) {
405
+ return null;
406
+ }
407
+ return _getElectrumTransactionInfoFromPayment(response.payment!);
408
}
409
410
Future<String> refundDeposit(
396
- String txId, int vout, String destinationAddress, BigInt feeRate) async {
411
+ String txId,
412
+ int vout,
413
+ String destinationAddress,
414
+ BigInt feeRate,
415
+ ) async {
416
final response = await sdk.refundDeposit(
417
request: RefundDepositRequest(
418
txid: txId,
@@ -464,17 +483,16 @@ class LightningWallet {
483
);
484
}
485
467
- ElectrumTransactionInfo _getElectrumTransactionInfoFromDepositInfo(DepositInfo deposit) {
468
- return ElectrumTransactionInfo(
469
- WalletType.bitcoin,
470
- id: deposit.txid,
471
- amount: Money(deposit.amountSats, currency),
472
- direction: TransactionDirection.incoming,
473
- isPending: true,
474
- fee: Money.zero(currency),
475
- date: DateTime.now(),
476
- confirmations: 0,
477
- additionalInfo: {"isLightning": true, "isSparkDeposit": true},
478
- );
479
- }
486
+ ElectrumTransactionInfo _getElectrumTransactionInfoFromDepositInfo(DepositInfo deposit) =>
487
+ ElectrumTransactionInfo(
488
+ WalletType.bitcoin,
489
+ id: deposit.txid,
490
+ amount: Money(deposit.amountSats, currency),
491
+ direction: TransactionDirection.incoming,
492
+ isPending: true,
493
+ fee: Money.zero(currency),
494
+ date: DateTime.now(),
495
+ confirmations: 0,
496
+ additionalInfo: {"isLightning": true, "isSparkDeposit": true},
497
+ );
498
}
cw_bitcoin/pubspec.yaml
+1
-1
@@ -72,7 +72,7 @@ dependencies:
72
breez_sdk_spark_flutter:
73
git:
74
url: https://github.com/breez/breez-sdk-spark-flutter
75
- ref: v0.14.0
75
+ ref: v0.23.0
76
77
dev_dependencies:
78
flutter_test:
pubspec_overrides.yaml
+1
-1
@@ -120,7 +120,7 @@ dependency_overrides:
120
breez_sdk_spark_flutter:
121
git:
122
url: https://github.com/breez/breez-sdk-spark-flutter
123
- ref: e18b6437daaf0572de6aea2439c2ec4d22658bbb
123
+ ref: 5943a3e773203f21728f87f1c0779040db8f2c28
124
bs58:
125
git:
126
url: https://github.com/litaoh/base58