Skip to content

Commit

Permalink
Merge pull request #3934 from sqrrm/allow-missing-multisig-entry
Browse files Browse the repository at this point in the history
Finalize multisig payout even on missing address entry
  • Loading branch information
ripcurlx authored Feb 3, 2020
2 parents cad09aa + 3470b73 commit 9bf3165
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import lombok.extern.slf4j.Slf4j;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

@Slf4j
Expand Down Expand Up @@ -70,10 +69,21 @@ protected void run() {
final byte[] buyerMultiSigPubKey = tradingPeer.getMultiSigPubKey();
byte[] sellerMultiSigPubKey = processModel.getMyMultiSigPubKey();

Optional<AddressEntry> MultiSigAddressEntryOptional = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG);
checkArgument(MultiSigAddressEntryOptional.isPresent() && Arrays.equals(sellerMultiSigPubKey,
MultiSigAddressEntryOptional.get().getPubKey()),
"sellerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id);
Optional<AddressEntry> multiSigAddressEntryOptional = walletService.getAddressEntry(id,
AddressEntry.Context.MULTI_SIG);
if (!multiSigAddressEntryOptional.isPresent() || !Arrays.equals(sellerMultiSigPubKey,
multiSigAddressEntryOptional.get().getPubKey())) {
// In some error edge cases it can be that the address entry is not marked (or was unmarked).
// We do not want to fail in that case and only report a warning.
// One case where that helped to avoid a failed payout attempt was when the taker had a power failure
// at the moment when the offer was taken. This caused first to not see step 1 in the trade process
// (all greyed out) but after the deposit tx was confirmed the trade process was on step 2 and
// everything looked ok. At the payout multiSigAddressEntryOptional was not present and payout
// could not be done. By changing the previous behaviour from fail if multiSigAddressEntryOptional
// is not present to only log a warning the payout worked.
log.warn("sellerMultiSigPubKey from AddressEntry does not match the one from the trade data. " +
"Trade id ={}, multiSigAddressEntryOptional={}", id, multiSigAddressEntryOptional);
}

DeterministicKey multiSigKeyPair = walletService.getMultiSigKeyPair(id, sellerMultiSigPubKey);

Expand Down

0 comments on commit 9bf3165

Please sign in to comment.