mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
fix stonewallx2 transaction address selection
This commit is contained in:
parent
594a873f20
commit
5696e00cb5
4 changed files with 16 additions and 13 deletions
|
@ -189,8 +189,6 @@ application {
|
|||
"--add-opens=java.base/java.net=com.sparrowwallet.sparrow",
|
||||
"--add-opens=java.base/java.io=com.google.gson",
|
||||
"--add-opens=java.smartcardio/sun.security.smartcardio=com.sparrowwallet.sparrow",
|
||||
"--add-opens=com.samourai.whirlpool.client/com.samourai.whirlpool.client.whirlpool=com.sparrowwallet.sparrow",
|
||||
"--add-opens=com.samourai.soroban.client/com.samourai.soroban.client.rpc=com.sparrowwallet.sparrow",
|
||||
"--add-reads=kotlin.stdlib=kotlinx.coroutines.core"]
|
||||
|
||||
if(os.macOsX) {
|
||||
|
@ -240,8 +238,6 @@ jlink {
|
|||
"--add-opens=java.base/java.net=com.sparrowwallet.sparrow",
|
||||
"--add-opens=java.base/java.io=com.google.gson",
|
||||
"--add-opens=java.smartcardio/sun.security.smartcardio=com.sparrowwallet.sparrow",
|
||||
"--add-opens=com.samourai.whirlpool.client/com.samourai.whirlpool.client.whirlpool=com.sparrowwallet.sparrow",
|
||||
"--add-opens=com.samourai.soroban.client/com.samourai.soroban.client.rpc=com.sparrowwallet.sparrow",
|
||||
"--add-reads=com.sparrowwallet.merged.module=java.desktop",
|
||||
"--add-reads=com.sparrowwallet.merged.module=java.sql",
|
||||
"--add-reads=com.sparrowwallet.merged.module=com.sparrowwallet.sparrow",
|
||||
|
|
|
@ -264,7 +264,7 @@ public class CounterpartyController extends SorobanController {
|
|||
.subscribe(responseMessage -> {
|
||||
requestUserAttention();
|
||||
if(accepted) {
|
||||
startCounterpartyCollaboration(sorobanWalletCounterparty, paymentCodeInitiator, cahootsType, soroban.getBip47Account());
|
||||
startCounterpartyCollaboration(sorobanWalletCounterparty, paymentCodeInitiator, cahootsType, cahootsWallet.getAccount());
|
||||
followPaymentCode(paymentCodeInitiator);
|
||||
}
|
||||
}, error -> {
|
||||
|
|
|
@ -63,6 +63,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import static com.sparrowwallet.sparrow.AppServices.showErrorDialog;
|
||||
|
@ -424,7 +425,7 @@ public class InitiatorController extends SorobanController {
|
|||
|
||||
Payment payment = walletTransaction.getPayments().get(0);
|
||||
long feePerB = (long)walletTransaction.getFeeRate();
|
||||
CahootsContext cahootsContext = CahootsContext.newInitiator(cahootsWallet, cahootsType, soroban.getBip47Account(), feePerB, payment.getAmount(), payment.getAddress().getAddress(), paymentCodeCounterparty.toString());
|
||||
CahootsContext cahootsContext = CahootsContext.newInitiator(cahootsWallet, cahootsType, cahootsWallet.getAccount(), feePerB, payment.getAmount(), payment.getAddress().getAddress(), paymentCodeCounterparty.toString());
|
||||
|
||||
CahootsSorobanInitiatorListener listener = new CahootsSorobanInitiatorListener() {
|
||||
@Override
|
||||
|
@ -684,9 +685,10 @@ public class InitiatorController extends SorobanController {
|
|||
}
|
||||
|
||||
private static String getErrorMessage(Throwable error) {
|
||||
String message = error.getMessage() == null ? (error instanceof TimeoutException ? "Timed out receiving meeting response" : "Error receiving meeting response") : error.getMessage();
|
||||
String cutFrom = "Exception: ";
|
||||
int index = error.getMessage().lastIndexOf(cutFrom);
|
||||
String msg = index < 0 ? error.getMessage() : error.getMessage().substring(index + cutFrom.length());
|
||||
int index = message.lastIndexOf(cutFrom);
|
||||
String msg = index < 0 ? message : message.substring(index + cutFrom.length());
|
||||
msg = msg.replace("#Cahoots", "mix transaction");
|
||||
msg = msg.endsWith(".") ? msg : msg + ".";
|
||||
return msg;
|
||||
|
|
|
@ -21,14 +21,17 @@ import com.sparrowwallet.drongo.wallet.WalletNode;
|
|||
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SparrowCahootsWallet extends AbstractCahootsWallet {
|
||||
private final Wallet wallet;
|
||||
private final HD_Wallet bip84w;
|
||||
private final int account;
|
||||
private final List<CahootsUtxo> utxos;
|
||||
private final Map<KeyPurpose, WalletNode> lastWalletNodes = new HashMap<>();
|
||||
|
||||
public SparrowCahootsWallet(ChainSupplier chainSupplier, Wallet wallet, HD_Wallet bip84w, int bip47Account) {
|
||||
super(chainSupplier, bip84w.getFingerprint(), new BIP47Wallet(bip84w).getAccount(bip47Account));
|
||||
|
@ -59,15 +62,15 @@ public class SparrowCahootsWallet extends AbstractCahootsWallet {
|
|||
protected String doFetchAddressReceive(int account, boolean increment, BipFormat bipFormat) throws Exception {
|
||||
if(account == StandardAccount.WHIRLPOOL_POSTMIX.getAccountNumber()) {
|
||||
// force change chain
|
||||
return getAddress(account, KeyPurpose.CHANGE);
|
||||
return getAddress(account, increment, KeyPurpose.CHANGE);
|
||||
}
|
||||
|
||||
return getAddress(account, KeyPurpose.RECEIVE);
|
||||
return getAddress(account, increment, KeyPurpose.RECEIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doFetchAddressChange(int account, boolean increment, BipFormat bipFormat) throws Exception {
|
||||
return getAddress(account, KeyPurpose.CHANGE);
|
||||
return getAddress(account, increment, KeyPurpose.CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,8 +78,10 @@ public class SparrowCahootsWallet extends AbstractCahootsWallet {
|
|||
return utxos;
|
||||
}
|
||||
|
||||
private String getAddress(int account, KeyPurpose keyPurpose) {
|
||||
return getWallet(account).getFreshNode(keyPurpose).getAddress().getAddress();
|
||||
private String getAddress(int account, boolean increment, KeyPurpose keyPurpose) {
|
||||
WalletNode addressNode = getWallet(account).getFreshNode(keyPurpose, increment ? lastWalletNodes.get(keyPurpose) : null);
|
||||
lastWalletNodes.put(keyPurpose, addressNode);
|
||||
return addressNode.getAddress().getAddress();
|
||||
}
|
||||
|
||||
private Wallet getWallet(int account) {
|
||||
|
|
Loading…
Reference in a new issue