Move contractHash creation to MakerCreateAndSignContract

This commit is contained in:
chimp1984 2020-09-21 23:26:51 -05:00
parent 0f36ae8928
commit 538db2f36f
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
2 changed files with 6 additions and 5 deletions

View file

@ -26,7 +26,6 @@ import bisq.core.trade.Trade;
import bisq.core.trade.protocol.TradingPeer;
import bisq.core.trade.protocol.tasks.TradeTask;
import bisq.common.crypto.Hash;
import bisq.common.taskrunner.TaskRunner;
import org.bitcoinj.core.Address;
@ -60,9 +59,6 @@ public class BuyerAsMakerCreatesAndSignsDepositTx extends TradeTask {
TradingPeer tradingPeer = processModel.getTradingPeer();
Offer offer = checkNotNull(trade.getOffer());
byte[] contractHash = Hash.getSha256Hash(checkNotNull(trade.getContractAsJson()));
trade.setContractHash(contractHash);
Coin makerInputAmount = offer.getBuyerSecurityDeposit();
Optional<AddressEntry> addressEntryOptional = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG);
checkArgument(addressEntryOptional.isPresent(), "addressEntryOptional must be present");
@ -87,7 +83,7 @@ public class BuyerAsMakerCreatesAndSignsDepositTx extends TradeTask {
"buyerPubKey from AddressEntry must match the one from the trade data. trade id =" + id);
PreparedDepositTxAndMakerInputs result = processModel.getTradeWalletService().buyerAsMakerCreatesAndSignsDepositTx(
contractHash,
trade.getContractHash(),
makerInputAmount,
msOutputAmount,
takerRawTransactionInputs,

View file

@ -27,6 +27,7 @@ import bisq.core.trade.protocol.tasks.TradeTask;
import bisq.network.p2p.NodeAddress;
import bisq.common.crypto.Hash;
import bisq.common.crypto.Sig;
import bisq.common.taskrunner.TaskRunner;
import bisq.common.util.Utilities;
@ -93,6 +94,10 @@ public class MakerCreateAndSignContract extends TradeTask {
trade.setContract(contract);
trade.setContractAsJson(contractAsJson);
trade.setMakerContractSignature(signature);
byte[] contractHash = Hash.getSha256Hash(checkNotNull(trade.getContractAsJson()));
trade.setContractHash(contractHash);
processModel.setMyMultiSigPubKey(makerMultiSigPubKey);
complete();