From 2544e0cd584153d4b75aadf91a525bc30cdb2ccf Mon Sep 17 00:00:00 2001 From: malik1004x Date: Sat, 18 Apr 2026 00:03:13 +0200 Subject: [PATCH] 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 --- cw_bitcoin/lib/bitcoin_wallet_addresses.dart | 4 ++-- cw_bitcoin/lib/electrum_wallet_addresses.dart | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cw_bitcoin/lib/bitcoin_wallet_addresses.dart b/cw_bitcoin/lib/bitcoin_wallet_addresses.dart index 40dd15d05..be03f26d0 100644 --- a/cw_bitcoin/lib/bitcoin_wallet_addresses.dart +++ b/cw_bitcoin/lib/bitcoin_wallet_addresses.dart @@ -74,7 +74,7 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S Future initPayjoin() async { try { await payjoinManager.initPayjoin(); - currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(primaryAddress); + currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(payjoinCompatibleAddress); payjoinEndpoint = (await currentPayjoinReceiver?.pjUri())?.pjEndpoint(); payjoinManager.resumeSessions(); @@ -88,7 +88,7 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S @action Future newPayjoinReceiver() async { try { - currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(primaryAddress); + currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(payjoinCompatibleAddress); payjoinEndpoint = (await currentPayjoinReceiver?.pjUri())?.pjEndpoint(); payjoinManager.spawnReceiver(receiver: currentPayjoinReceiver!); diff --git a/cw_bitcoin/lib/electrum_wallet_addresses.dart b/cw_bitcoin/lib/electrum_wallet_addresses.dart index 2cfad69dd..d3763386d 100644 --- a/cw_bitcoin/lib/electrum_wallet_addresses.dart +++ b/cw_bitcoin/lib/electrum_wallet_addresses.dart @@ -290,6 +290,16 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store { return getAddress(index: 0, hd: mainHd, addressType: addressPageType); } + String get payjoinCompatibleAddress { + final addrType = (addressPageType == SilentPaymentsAddresType.p2sp || + addressPageType == LightningAddressType.p2l) + ? SegwitAddresType.p2wpkh + : addressPageType; + + final mainHd = mainHdByType[addrType] ?? mainHdByType.values.first; + return getAddress(index: 0, hd: mainHd, addressType: addrType); + } + Map currentReceiveAddressIndexByType; int get currentReceiveAddressIndex =>