mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-11-10 05:03:35 +01:00
import multisig hex individually if one is invalid
This commit is contained in:
parent
8cdd65e7dd
commit
c29cdb8b0f
@ -274,15 +274,15 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
|||||||
}
|
}
|
||||||
dispute.setDisputeResult(disputeResult);
|
dispute.setDisputeResult(disputeResult);
|
||||||
|
|
||||||
// sync and save wallet
|
|
||||||
if (!trade.isPayoutPublished()) trade.syncAndPollWallet();
|
|
||||||
|
|
||||||
// update multisig hex
|
// update multisig hex
|
||||||
if (disputeClosedMessage.getUpdatedMultisigHex() != null) trade.getArbitrator().setUpdatedMultisigHex(disputeClosedMessage.getUpdatedMultisigHex());
|
if (disputeClosedMessage.getUpdatedMultisigHex() != null) trade.getArbitrator().setUpdatedMultisigHex(disputeClosedMessage.getUpdatedMultisigHex());
|
||||||
if (trade.walletExists()) trade.importMultisigHex();
|
if (trade.walletExists()) trade.importMultisigHex();
|
||||||
|
|
||||||
|
// sync and save wallet
|
||||||
|
if (!trade.isPayoutPublished()) trade.syncAndPollWallet();
|
||||||
|
|
||||||
// attempt to sign and publish dispute payout tx if given and not already published
|
// attempt to sign and publish dispute payout tx if given and not already published
|
||||||
if (disputeClosedMessage.getUnsignedPayoutTxHex() != null && !trade.isPayoutPublished()) {
|
if (!trade.isPayoutPublished() && disputeClosedMessage.getUnsignedPayoutTxHex() != null) {
|
||||||
|
|
||||||
// wait to sign and publish payout tx if defer flag set
|
// wait to sign and publish payout tx if defer flag set
|
||||||
if (disputeClosedMessage.isDeferPublishPayout()) {
|
if (disputeClosedMessage.isDeferPublishPayout()) {
|
||||||
|
@ -92,6 +92,7 @@ import javafx.collections.ObservableList;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import monero.common.MoneroError;
|
||||||
import monero.common.MoneroRpcConnection;
|
import monero.common.MoneroRpcConnection;
|
||||||
import monero.common.TaskLooper;
|
import monero.common.TaskLooper;
|
||||||
import monero.daemon.MoneroDaemon;
|
import monero.daemon.MoneroDaemon;
|
||||||
@ -886,6 +887,8 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
try {
|
try {
|
||||||
doImportMultisigHex();
|
doImportMultisigHex();
|
||||||
break;
|
break;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to import multisig hex, attempt={}/{}, tradeId={}, error={}", i + 1, TradeProtocol.MAX_ATTEMPTS, getShortId(), e.getMessage());
|
log.warn("Failed to import multisig hex, attempt={}/{}, tradeId={}, error={}", i + 1, TradeProtocol.MAX_ATTEMPTS, getShortId(), e.getMessage());
|
||||||
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
||||||
@ -909,12 +912,44 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
log.info("Importing multisig hexes for {} {}, count={}", getClass().getSimpleName(), getShortId(), multisigHexes.size());
|
log.info("Importing multisig hexes for {} {}, count={}", getClass().getSimpleName(), getShortId(), multisigHexes.size());
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
if (!multisigHexes.isEmpty()) {
|
if (!multisigHexes.isEmpty()) {
|
||||||
wallet.importMultisigHex(multisigHexes.toArray(new String[0]));
|
try {
|
||||||
|
wallet.importMultisigHex(multisigHexes.toArray(new String[0]));
|
||||||
|
} catch (MoneroError e) {
|
||||||
|
|
||||||
|
// import multisig hex individually if one is invalid
|
||||||
|
if (isInvalidImportError(e.getMessage())) {
|
||||||
|
log.warn("Peer has invalid multisig hex for {} {}, importing individually", getClass().getSimpleName(), getShortId());
|
||||||
|
boolean imported = false;
|
||||||
|
Exception lastError = null;
|
||||||
|
for (TradePeer peer : getOtherPeers()) {
|
||||||
|
if (peer.getUpdatedMultisigHex() == null) continue;
|
||||||
|
try {
|
||||||
|
wallet.importMultisigHex(peer.getUpdatedMultisigHex());
|
||||||
|
imported = true;
|
||||||
|
} catch (MoneroError e2) {
|
||||||
|
lastError = e2;
|
||||||
|
if (isInvalidImportError(e2.getMessage())) {
|
||||||
|
log.warn("{} has invalid multisig hex for {} {}, error={}, multisigHex={}", getPeerRole(peer), getClass().getSimpleName(), getShortId(), e2.getMessage(), peer.getUpdatedMultisigHex());
|
||||||
|
} else {
|
||||||
|
throw e2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!imported) throw new IllegalArgumentException("Could not import any multisig hexes for " + getClass().getSimpleName() + " " + getShortId(), lastError);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
requestSaveWallet();
|
requestSaveWallet();
|
||||||
}
|
}
|
||||||
log.info("Done importing multisig hexes for {} {} in {} ms, count={}", getClass().getSimpleName(), getShortId(), System.currentTimeMillis() - startTime, multisigHexes.size());
|
log.info("Done importing multisig hexes for {} {} in {} ms, count={}", getClass().getSimpleName(), getShortId(), System.currentTimeMillis() - startTime, multisigHexes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: checking error strings isn't robust, but the library doesn't provide a way to check if multisig hex is invalid. throw IllegalArgumentException from library on invalid multisig hex?
|
||||||
|
private boolean isInvalidImportError(String errMsg) {
|
||||||
|
return errMsg.contains("Failed to parse hex") || errMsg.contains("Multisig info is for a different account");
|
||||||
|
}
|
||||||
|
|
||||||
public void changeWalletPassword(String oldPassword, String newPassword) {
|
public void changeWalletPassword(String oldPassword, String newPassword) {
|
||||||
synchronized (walletLock) {
|
synchronized (walletLock) {
|
||||||
getWallet().changePassword(oldPassword, newPassword);
|
getWallet().changePassword(oldPassword, newPassword);
|
||||||
|
Loading…
Reference in New Issue
Block a user