payjoin address getter fix (#3191)
* payjoin address getter fix * fix payjoin getter address type * Update cw_bitcoin/lib/electrum_wallet_addresses.dart --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
malik1004x committed
Apr 18, 2026 at 00:03 UTC
2544e0cd584153d4b75aadf91a525bc30cdb2ccf
2 files changed
+12
-2
cw_bitcoin/lib/bitcoin_wallet_addresses.dart
+2
-2
@@ -74,7 +74,7 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S
74
Future<void> initPayjoin() async {
75
try {
76
await payjoinManager.initPayjoin();
77
- currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(primaryAddress);
77
+ currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(payjoinCompatibleAddress);
78
payjoinEndpoint = (await currentPayjoinReceiver?.pjUri())?.pjEndpoint();
79
80
payjoinManager.resumeSessions();
@@ -88,7 +88,7 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S
88
@action
89
Future<void> newPayjoinReceiver() async {
90
try {
91
- currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(primaryAddress);
91
+ currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(payjoinCompatibleAddress);
92
payjoinEndpoint = (await currentPayjoinReceiver?.pjUri())?.pjEndpoint();
93
94
payjoinManager.spawnReceiver(receiver: currentPayjoinReceiver!);
cw_bitcoin/lib/electrum_wallet_addresses.dart
+10
@@ -290,6 +290,16 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
290
return getAddress(index: 0, hd: mainHd, addressType: addressPageType);
291
}
292
293
+ String get payjoinCompatibleAddress {
294
+ final addrType = (addressPageType == SilentPaymentsAddresType.p2sp ||
295
+ addressPageType == LightningAddressType.p2l)
296
+ ? SegwitAddresType.p2wpkh
297
+ : addressPageType;
298
+
299
+ final mainHd = mainHdByType[addrType] ?? mainHdByType.values.first;
300
+ return getAddress(index: 0, hd: mainHd, addressType: addrType);
301
+ }
302
+
303
Map<String, int> currentReceiveAddressIndexByType;
304
305
int get currentReceiveAddressIndex =>