Move contractHash creation to TakerVerifyAndSignContract

This commit is contained in:
chimp1984 2020-09-21 22:25:48 -05:00
parent 2aa5feebc1
commit 9966f9a9a8
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
2 changed files with 6 additions and 10 deletions

View file

@ -25,7 +25,6 @@ import bisq.core.trade.Trade;
import bisq.core.trade.protocol.TradingPeer; import bisq.core.trade.protocol.TradingPeer;
import bisq.core.trade.protocol.tasks.TradeTask; import bisq.core.trade.protocol.tasks.TradeTask;
import bisq.common.crypto.Hash;
import bisq.common.taskrunner.TaskRunner; import bisq.common.taskrunner.TaskRunner;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@ -50,13 +49,6 @@ public class SellerAsTakerSignsDepositTx extends TradeTask {
protected void run() { protected void run() {
try { try {
runInterceptHook(); runInterceptHook();
log.debug("\n\n------------------------------------------------------------\n"
+ "Contract as json\n"
+ trade.getContractAsJson()
+ "\n------------------------------------------------------------\n");
byte[] contractHash = Hash.getSha256Hash(checkNotNull(trade.getContractAsJson()));
trade.setContractHash(contractHash);
List<RawTransactionInput> sellerInputs = checkNotNull(processModel.getRawTransactionInputs(), "sellerInputs must not be null"); List<RawTransactionInput> sellerInputs = checkNotNull(processModel.getRawTransactionInputs(), "sellerInputs must not be null");
BtcWalletService walletService = processModel.getBtcWalletService(); BtcWalletService walletService = processModel.getBtcWalletService();
@ -79,7 +71,7 @@ public class SellerAsTakerSignsDepositTx extends TradeTask {
Transaction depositTx = processModel.getTradeWalletService().takerSignsDepositTx( Transaction depositTx = processModel.getTradeWalletService().takerSignsDepositTx(
true, true,
contractHash, trade.getContractHash(),
processModel.getPreparedDepositTx(), processModel.getPreparedDepositTx(),
checkNotNull(tradingPeer.getRawTransactionInputs()), checkNotNull(tradingPeer.getRawTransactionInputs()),
sellerInputs, sellerInputs,

View file

@ -28,6 +28,7 @@ import bisq.core.trade.protocol.tasks.TradeTask;
import bisq.network.p2p.NodeAddress; import bisq.network.p2p.NodeAddress;
import bisq.common.crypto.Hash;
import bisq.common.crypto.Sig; import bisq.common.crypto.Sig;
import bisq.common.taskrunner.TaskRunner; import bisq.common.taskrunner.TaskRunner;
import bisq.common.util.Utilities; import bisq.common.util.Utilities;
@ -108,13 +109,16 @@ public class TakerVerifyAndSignContract extends TradeTask {
String signature = Sig.sign(processModel.getKeyRing().getSignatureKeyPair().getPrivate(), contractAsJson); String signature = Sig.sign(processModel.getKeyRing().getSignatureKeyPair().getPrivate(), contractAsJson);
trade.setContract(contract); trade.setContract(contract);
trade.setContractAsJson(contractAsJson); trade.setContractAsJson(contractAsJson);
byte[] contractHash = Hash.getSha256Hash(checkNotNull(contractAsJson));
trade.setContractHash(contractHash);
trade.setTakerContractSignature(signature); trade.setTakerContractSignature(signature);
try { try {
checkNotNull(maker.getPubKeyRing(), "maker.getPubKeyRing() must nto be null"); checkNotNull(maker.getPubKeyRing(), "maker.getPubKeyRing() must nto be null");
Sig.verify(maker.getPubKeyRing().getSignaturePubKey(), Sig.verify(maker.getPubKeyRing().getSignaturePubKey(),
contractAsJson, contractAsJson,
maker.getContractSignature()); maker.getContractSignature());
complete(); complete();
} catch (Throwable t) { } catch (Throwable t) {
failed("Contract signature verification failed. " + t.getMessage()); failed("Contract signature verification failed. " + t.getMessage());