mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
allow stowaway counterparty to spend postmix utxos but receive to master wallet
This commit is contained in:
parent
7915bbfa47
commit
961fd94dd6
3 changed files with 22 additions and 18 deletions
|
@ -121,7 +121,7 @@ dependencies {
|
|||
implementation('org.slf4j:jul-to-slf4j:1.7.30') {
|
||||
exclude group: 'org.slf4j'
|
||||
}
|
||||
implementation('com.sparrowwallet.nightjar:nightjar:0.2.35')
|
||||
implementation('com.sparrowwallet.nightjar:nightjar:0.2.36')
|
||||
implementation('io.reactivex.rxjava2:rxjava:2.2.15')
|
||||
implementation('io.reactivex.rxjava2:rxjavafx:2.2.2')
|
||||
implementation('org.apache.commons:commons-lang3:3.7')
|
||||
|
@ -508,7 +508,7 @@ extraJavaModuleInfo {
|
|||
exports('co.nstant.in.cbor.model')
|
||||
exports('co.nstant.in.cbor.builder')
|
||||
}
|
||||
module('nightjar-0.2.35.jar', 'com.sparrowwallet.nightjar', '0.2.35') {
|
||||
module('nightjar-0.2.36.jar', 'com.sparrowwallet.nightjar', '0.2.36') {
|
||||
requires('com.google.common')
|
||||
requires('net.sourceforge.streamsupport')
|
||||
requires('org.slf4j')
|
||||
|
|
|
@ -294,20 +294,10 @@ public class CounterpartyController extends SorobanController {
|
|||
sorobanProgressLabel.setText("Creating mix transaction...");
|
||||
|
||||
Soroban soroban = AppServices.getSorobanServices().getSoroban(walletId);
|
||||
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();
|
||||
Map<BlockTransactionHashIndex, WalletNode> walletUtxos = wallet.getWalletUtxos();
|
||||
for(Map.Entry<BlockTransactionHashIndex, WalletNode> entry : walletUtxos.entrySet()) {
|
||||
if(entry.getKey().getStatus() != Status.FROZEN) {
|
||||
counterpartyCahootsWallet.addUtxo(entry.getValue(), counterpartyWallet.getWalletTransaction(entry.getKey().getHash()), (int)entry.getKey().getIndex());
|
||||
counterpartyCahootsWallet.addUtxo(entry.getValue(), wallet.getWalletTransaction(entry.getKey().getHash()), (int)entry.getKey().getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,7 +321,7 @@ public class CounterpartyController extends SorobanController {
|
|||
Transaction transaction = getTransaction(cahoots);
|
||||
if(transaction != null) {
|
||||
transactionProperty.set(transaction);
|
||||
updateTransactionDiagram(transactionDiagram, counterpartyWallet, null, transaction);
|
||||
updateTransactionDiagram(transactionDiagram, wallet, null, transaction);
|
||||
next();
|
||||
}
|
||||
} catch(PSBTParseException e) {
|
||||
|
|
|
@ -34,6 +34,12 @@ public class SparrowCahootsWallet extends SimpleCahootsWallet {
|
|||
this.bip47Account = bip47Account;
|
||||
bip84w.getAccount(account).getReceive().setAddrIdx(wallet.getFreshNode(KeyPurpose.RECEIVE).getIndex());
|
||||
bip84w.getAccount(account).getChange().setAddrIdx(wallet.getFreshNode(KeyPurpose.CHANGE).getIndex());
|
||||
|
||||
if(!wallet.isMasterWallet() && account != 0) {
|
||||
Wallet masterWallet = wallet.getMasterWallet();
|
||||
bip84w.getAccount(0).getReceive().setAddrIdx(masterWallet.getFreshNode(KeyPurpose.RECEIVE).getIndex());
|
||||
bip84w.getAccount(0).getChange().setAddrIdx(masterWallet.getFreshNode(KeyPurpose.CHANGE).getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
public void addUtxo(WalletNode node, BlockTransaction blockTransaction, int index) {
|
||||
|
@ -84,15 +90,23 @@ public class SparrowCahootsWallet extends SimpleCahootsWallet {
|
|||
public Pair<Integer, Integer> fetchReceiveIndex(int account) throws Exception {
|
||||
if(account == StandardAccount.WHIRLPOOL_POSTMIX.getAccountNumber()) {
|
||||
// force change chain
|
||||
return Pair.of(wallet.getFreshNode(KeyPurpose.CHANGE).getIndex(), 1);
|
||||
return Pair.of(getWallet(account).getFreshNode(KeyPurpose.CHANGE).getIndex(), 1);
|
||||
}
|
||||
|
||||
return Pair.of(wallet.getFreshNode(KeyPurpose.RECEIVE).getIndex(), 0);
|
||||
return Pair.of(getWallet(account).getFreshNode(KeyPurpose.RECEIVE).getIndex(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> fetchChangeIndex(int account) throws Exception {
|
||||
return Pair.of(wallet.getFreshNode(KeyPurpose.CHANGE).getIndex(), 1);
|
||||
return Pair.of(getWallet(account).getFreshNode(KeyPurpose.CHANGE).getIndex(), 1);
|
||||
}
|
||||
|
||||
private Wallet getWallet(int account) {
|
||||
if(account != this.account && account == 0 && !wallet.isMasterWallet()) {
|
||||
return wallet.getMasterWallet();
|
||||
}
|
||||
|
||||
return wallet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue