From 0bc5300a27498c2013e1b13353652a4d6e0c3d2a Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 15 Nov 2023 12:17:25 -0500 Subject: [PATCH] synchronize on wallet while importing multisig hex --- .../src/main/java/haveno/core/trade/Trade.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index a860894442..61014459cc 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -788,14 +788,16 @@ public abstract class Trade implements Tradable, Model { } public void importMultisigHex() { - List multisigHexes = new ArrayList(); - if (getBuyer().getUpdatedMultisigHex() != null) multisigHexes.add(getBuyer().getUpdatedMultisigHex()); - if (getSeller().getUpdatedMultisigHex() != null) multisigHexes.add(getSeller().getUpdatedMultisigHex()); - if (getArbitrator().getUpdatedMultisigHex() != null) multisigHexes.add(getArbitrator().getUpdatedMultisigHex()); - if (!multisigHexes.isEmpty()) { - log.info("Importing multisig hex for {} {}", getClass().getSimpleName(), getId()); - getWallet().importMultisigHex(multisigHexes.toArray(new String[0])); - log.info("Done importing multisig hex for {} {}", getClass().getSimpleName(), getId()); + synchronized (walletLock) { + List multisigHexes = new ArrayList(); + if (getBuyer().getUpdatedMultisigHex() != null) multisigHexes.add(getBuyer().getUpdatedMultisigHex()); + if (getSeller().getUpdatedMultisigHex() != null) multisigHexes.add(getSeller().getUpdatedMultisigHex()); + if (getArbitrator().getUpdatedMultisigHex() != null) multisigHexes.add(getArbitrator().getUpdatedMultisigHex()); + if (!multisigHexes.isEmpty()) { + log.info("Importing multisig hex for {} {}", getClass().getSimpleName(), getId()); + getWallet().importMultisigHex(multisigHexes.toArray(new String[0])); + log.info("Done importing multisig hex for {} {}", getClass().getSimpleName(), getId()); + } } }