Merge pull request #3934 from sqrrm/allow-missing-multisig-entry

Finalize multisig payout even on missing address entry
This commit is contained in:
Christoph Atteneder 2020-02-03 11:40:48 +01:00 committed by GitHub
commit 9bf3165e02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,7 +35,6 @@ import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j
@ -70,10 +69,21 @@ public class SellerSignAndFinalizePayoutTx extends TradeTask {
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);