fix error receiving a stowaway to postmix by reverting to master wallet

This commit is contained in:
Craig Raw 2023-02-13 18:27:21 +02:00
parent ea6b30326e
commit e3799cd0a8
2 changed files with 18 additions and 8 deletions

View file

@ -8,13 +8,9 @@ import com.samourai.wallet.cahoots.Cahoots;
import com.samourai.wallet.cahoots.CahootsType;
import com.sparrowwallet.drongo.protocol.Transaction;
import com.sparrowwallet.drongo.psbt.PSBTParseException;
import com.sparrowwallet.drongo.wallet.BlockTransactionHashIndex;
import com.sparrowwallet.drongo.wallet.Status;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.drongo.wallet.WalletNode;
import com.sparrowwallet.drongo.wallet.*;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.control.*;
import com.sparrowwallet.sparrow.io.Config;
import com.sparrowwallet.sparrow.paynym.PayNymDialog;
import com.sparrowwallet.sparrow.paynym.PayNymService;
import io.reactivex.rxjavafx.schedulers.JavaFxScheduler;
@ -298,10 +294,20 @@ public class CounterpartyController extends SorobanController {
sorobanProgressLabel.setText("Creating mix transaction...");
Soroban soroban = AppServices.getSorobanServices().getSoroban(walletId);
Map<BlockTransactionHashIndex, WalletNode> walletUtxos = wallet.getWalletUtxos();
Wallet counterpartyWallet;
if(counterpartyCahootsWallet.getAccount() == StandardAccount.WHIRLPOOL_POSTMIX.getAccountNumber() && cahootsType == CahootsType.STOWAWAY
&& !counterpartyCahootsWallet.getWallet().isMasterWallet()) {
//Counterparty cannot participate in Stowaway using Postmix wallet, switch to master wallet
counterpartyWallet = counterpartyCahootsWallet.getWallet().getMasterWallet();
counterpartyCahootsWallet = soroban.getCahootsWallet(counterpartyWallet, 1);
} else {
counterpartyWallet = wallet;
}
Map<BlockTransactionHashIndex, WalletNode> walletUtxos = counterpartyWallet.getWalletUtxos();
for(Map.Entry<BlockTransactionHashIndex, WalletNode> entry : walletUtxos.entrySet()) {
if(entry.getKey().getStatus() != Status.FROZEN) {
counterpartyCahootsWallet.addUtxo(entry.getValue(), wallet.getWalletTransaction(entry.getKey().getHash()), (int)entry.getKey().getIndex());
counterpartyCahootsWallet.addUtxo(entry.getValue(), counterpartyWallet.getWalletTransaction(entry.getKey().getHash()), (int)entry.getKey().getIndex());
}
}
@ -325,7 +331,7 @@ public class CounterpartyController extends SorobanController {
Transaction transaction = getTransaction(cahoots);
if(transaction != null) {
transactionProperty.set(transaction);
updateTransactionDiagram(transactionDiagram, wallet, null, transaction);
updateTransactionDiagram(transactionDiagram, counterpartyWallet, null, transaction);
next();
}
} catch(PSBTParseException e) {

View file

@ -62,6 +62,10 @@ public class SparrowCahootsWallet extends SimpleCahootsWallet {
addUtxo(account, cahootsUtxo);
}
public Wallet getWallet() {
return wallet;
}
public int getAccount() {
return account;
}