mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +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.net=com.sparrowwallet.sparrow",
|
||||||
"--add-opens=java.base/java.io=com.google.gson",
|
"--add-opens=java.base/java.io=com.google.gson",
|
||||||
"--add-opens=java.smartcardio/sun.security.smartcardio=com.sparrowwallet.sparrow",
|
"--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"]
|
"--add-reads=kotlin.stdlib=kotlinx.coroutines.core"]
|
||||||
|
|
||||||
if(os.macOsX) {
|
if(os.macOsX) {
|
||||||
|
@ -240,8 +238,6 @@ jlink {
|
||||||
"--add-opens=java.base/java.net=com.sparrowwallet.sparrow",
|
"--add-opens=java.base/java.net=com.sparrowwallet.sparrow",
|
||||||
"--add-opens=java.base/java.io=com.google.gson",
|
"--add-opens=java.base/java.io=com.google.gson",
|
||||||
"--add-opens=java.smartcardio/sun.security.smartcardio=com.sparrowwallet.sparrow",
|
"--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.desktop",
|
||||||
"--add-reads=com.sparrowwallet.merged.module=java.sql",
|
"--add-reads=com.sparrowwallet.merged.module=java.sql",
|
||||||
"--add-reads=com.sparrowwallet.merged.module=com.sparrowwallet.sparrow",
|
"--add-reads=com.sparrowwallet.merged.module=com.sparrowwallet.sparrow",
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class CounterpartyController extends SorobanController {
|
||||||
.subscribe(responseMessage -> {
|
.subscribe(responseMessage -> {
|
||||||
requestUserAttention();
|
requestUserAttention();
|
||||||
if(accepted) {
|
if(accepted) {
|
||||||
startCounterpartyCollaboration(sorobanWalletCounterparty, paymentCodeInitiator, cahootsType, soroban.getBip47Account());
|
startCounterpartyCollaboration(sorobanWalletCounterparty, paymentCodeInitiator, cahootsType, cahootsWallet.getAccount());
|
||||||
followPaymentCode(paymentCodeInitiator);
|
followPaymentCode(paymentCodeInitiator);
|
||||||
}
|
}
|
||||||
}, error -> {
|
}, error -> {
|
||||||
|
|
|
@ -63,6 +63,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
import static com.sparrowwallet.sparrow.AppServices.showErrorDialog;
|
import static com.sparrowwallet.sparrow.AppServices.showErrorDialog;
|
||||||
|
@ -424,7 +425,7 @@ public class InitiatorController extends SorobanController {
|
||||||
|
|
||||||
Payment payment = walletTransaction.getPayments().get(0);
|
Payment payment = walletTransaction.getPayments().get(0);
|
||||||
long feePerB = (long)walletTransaction.getFeeRate();
|
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() {
|
CahootsSorobanInitiatorListener listener = new CahootsSorobanInitiatorListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -684,9 +685,10 @@ public class InitiatorController extends SorobanController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getErrorMessage(Throwable error) {
|
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: ";
|
String cutFrom = "Exception: ";
|
||||||
int index = error.getMessage().lastIndexOf(cutFrom);
|
int index = message.lastIndexOf(cutFrom);
|
||||||
String msg = index < 0 ? error.getMessage() : error.getMessage().substring(index + cutFrom.length());
|
String msg = index < 0 ? message : message.substring(index + cutFrom.length());
|
||||||
msg = msg.replace("#Cahoots", "mix transaction");
|
msg = msg.replace("#Cahoots", "mix transaction");
|
||||||
msg = msg.endsWith(".") ? msg : msg + ".";
|
msg = msg.endsWith(".") ? msg : msg + ".";
|
||||||
return msg;
|
return msg;
|
||||||
|
|
|
@ -21,14 +21,17 @@ import com.sparrowwallet.drongo.wallet.WalletNode;
|
||||||
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
|
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
|
||||||
import org.bitcoinj.core.NetworkParameters;
|
import org.bitcoinj.core.NetworkParameters;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class SparrowCahootsWallet extends AbstractCahootsWallet {
|
public class SparrowCahootsWallet extends AbstractCahootsWallet {
|
||||||
private final Wallet wallet;
|
private final Wallet wallet;
|
||||||
private final HD_Wallet bip84w;
|
private final HD_Wallet bip84w;
|
||||||
private final int account;
|
private final int account;
|
||||||
private final List<CahootsUtxo> utxos;
|
private final List<CahootsUtxo> utxos;
|
||||||
|
private final Map<KeyPurpose, WalletNode> lastWalletNodes = new HashMap<>();
|
||||||
|
|
||||||
public SparrowCahootsWallet(ChainSupplier chainSupplier, Wallet wallet, HD_Wallet bip84w, int bip47Account) {
|
public SparrowCahootsWallet(ChainSupplier chainSupplier, Wallet wallet, HD_Wallet bip84w, int bip47Account) {
|
||||||
super(chainSupplier, bip84w.getFingerprint(), new BIP47Wallet(bip84w).getAccount(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 {
|
protected String doFetchAddressReceive(int account, boolean increment, BipFormat bipFormat) throws Exception {
|
||||||
if(account == StandardAccount.WHIRLPOOL_POSTMIX.getAccountNumber()) {
|
if(account == StandardAccount.WHIRLPOOL_POSTMIX.getAccountNumber()) {
|
||||||
// force change chain
|
// 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
|
@Override
|
||||||
protected String doFetchAddressChange(int account, boolean increment, BipFormat bipFormat) throws Exception {
|
protected String doFetchAddressChange(int account, boolean increment, BipFormat bipFormat) throws Exception {
|
||||||
return getAddress(account, KeyPurpose.CHANGE);
|
return getAddress(account, increment, KeyPurpose.CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,8 +78,10 @@ public class SparrowCahootsWallet extends AbstractCahootsWallet {
|
||||||
return utxos;
|
return utxos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAddress(int account, KeyPurpose keyPurpose) {
|
private String getAddress(int account, boolean increment, KeyPurpose keyPurpose) {
|
||||||
return getWallet(account).getFreshNode(keyPurpose).getAddress().getAddress();
|
WalletNode addressNode = getWallet(account).getFreshNode(keyPurpose, increment ? lastWalletNodes.get(keyPurpose) : null);
|
||||||
|
lastWalletNodes.put(keyPurpose, addressNode);
|
||||||
|
return addressNode.getAddress().getAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Wallet getWallet(int account) {
|
private Wallet getWallet(int account) {
|
||||||
|
|
Loading…
Reference in a new issue