Compare commits
3 commits
master
...
check_mult
Author | SHA1 | Date | |
---|---|---|---|
|
9f5a96a4d9 | ||
|
90f8c46746 | ||
|
963efe3810 |
2 changed files with 15 additions and 3 deletions
|
@ -1051,7 +1051,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
synchronized (HavenoUtils.getWalletFunctionLock()) {
|
||||
MoneroTxWallet tx = wallet.createTx(txConfig);
|
||||
exportMultisigHex();
|
||||
requestSaveWallet();
|
||||
saveWallet();
|
||||
return tx;
|
||||
}
|
||||
}
|
||||
|
@ -1152,7 +1152,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
requestSaveWallet();
|
||||
saveWallet();
|
||||
}
|
||||
log.info("Done importing multisig hexes for {} {} in {} ms, count={}", getClass().getSimpleName(), getShortId(), System.currentTimeMillis() - startTime, multisigHexes.size());
|
||||
}
|
||||
|
@ -1365,6 +1365,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
// verify fee is within tolerance by recreating payout tx
|
||||
// TODO (monero-project): creating tx will require exchanging updated multisig hex if message needs reprocessed. provide weight with describe_transfer so fee can be estimated?
|
||||
log.info("Creating fee estimate tx for {} {}", getClass().getSimpleName(), getId());
|
||||
saveWallet(); // save wallet before creating fee estimate tx
|
||||
MoneroTxWallet feeEstimateTx = createPayoutTx();
|
||||
BigInteger feeEstimate = feeEstimateTx.getFee();
|
||||
double feeDiff = payoutTx.getFee().subtract(feeEstimate).abs().doubleValue() / feeEstimate.doubleValue(); // TODO: use BigDecimal?
|
||||
|
@ -1373,6 +1374,7 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
}
|
||||
|
||||
// save trade state
|
||||
saveWallet();
|
||||
requestPersistence();
|
||||
|
||||
// submit payout tx
|
||||
|
|
|
@ -32,6 +32,7 @@ import haveno.network.p2p.NodeAddress;
|
|||
import haveno.network.p2p.SendDirectMessageListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import monero.wallet.MoneroWallet;
|
||||
import monero.wallet.model.MoneroMultisigInfo;
|
||||
import monero.wallet.model.MoneroMultisigInitResult;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -118,8 +119,17 @@ public class ProcessInitMultisigRequest extends TradeTask {
|
|||
if (processModel.getMultisigAddress() == null && peers[0].getExchangedMultisigHex() != null && peers[1].getExchangedMultisigHex() != null) {
|
||||
log.info("Importing exchanged multisig hex for trade {}", trade.getId());
|
||||
MoneroMultisigInitResult result = multisigWallet.exchangeMultisigKeys(Arrays.asList(peers[0].getExchangedMultisigHex(), peers[1].getExchangedMultisigHex()), xmrWalletService.getWalletPassword());
|
||||
|
||||
// check multisig state
|
||||
MoneroMultisigInfo multisigInfo = multisigWallet.getMultisigInfo();
|
||||
if (!multisigInfo.isMultisig()) throw new RuntimeException("Multisig wallet is not multisig on completion");
|
||||
if (!multisigInfo.isReady()) throw new RuntimeException("Multisig wallet is not ready on completion");
|
||||
if (multisigInfo.getThreshold() != 2) throw new RuntimeException("Multisig wallet has unexpected threshold: " + multisigInfo.getThreshold());
|
||||
if (multisigInfo.getNumParticipants() != 3) throw new RuntimeException("Multisig wallet has unexpected number of participants: " + multisigInfo.getNumParticipants());
|
||||
|
||||
// set final address and save
|
||||
processModel.setMultisigAddress(result.getAddress());
|
||||
new Thread(() -> trade.saveWallet()).start(); // save multisig wallet off thread on completion
|
||||
trade.saveWallet();
|
||||
trade.setStateIfValidTransitionTo(Trade.State.MULTISIG_COMPLETED);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue