Skip to content

Commit

Permalink
Finalize multisig payout even on missing address entry
Browse files Browse the repository at this point in the history
The check for an address entry before finalizing the multisig payout
might prevent a valid payout when the initiation of the trade process
was interrupted. It's better to allow the completion of the trade
and just log a warning.
  • Loading branch information
sqrrm committed Feb 3, 2020
1 parent cad09aa commit 3470b73
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 3470b73

Please sign in to comment.