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>
This commit is contained in:
malik1004x
2026-04-18 00:03:13 +02:00
committed by GitHub
co-authored by Omar Hatem
parent 1cb05d5211
commit 2544e0cd58
2 changed files with 12 additions and 2 deletions
+2 -2
View File
@@ -74,7 +74,7 @@ abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with S
Future<void> 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<void> newPayjoinReceiver() async {
try {
currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(primaryAddress);
currentPayjoinReceiver = await payjoinManager.getUnusedReceiver(payjoinCompatibleAddress);
payjoinEndpoint = (await currentPayjoinReceiver?.pjUri())?.pjEndpoint();
payjoinManager.spawnReceiver(receiver: currentPayjoinReceiver!);
@@ -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<String, int> currentReceiveAddressIndexByType;
int get currentReceiveAddressIndex =>