diff --git a/execution/execution.go b/execution/execution.go index 2fe05f133416bb1f24c00f0619d127438478a920..63328d29163886dbb956159aa78c4b6af367a56c 100644 --- a/execution/execution.go +++ b/execution/execution.go @@ -184,7 +184,7 @@ func (exe *executor) Execute(txEnv *txs.Envelope) (txe *exec.TxExecution, err er logger.TraceMsg("Executing transaction", "tx", txEnv.String()) // Verify transaction signature against inputs - err = txEnv.Verify(exe.stateCache) + err = txEnv.Verify(exe.stateCache, exe.blockchain.ChainID()) if err != nil { return nil, err } diff --git a/txs/envelope.go b/txs/envelope.go index 06ed3832a145f30c86cfbe41d66a5b58bfb8bc01..817f26e583f633fbd7ae841d800b95507ed669ef 100644 --- a/txs/envelope.go +++ b/txs/envelope.go @@ -77,12 +77,16 @@ func (txEnv *Envelope) Validate() error { // Verifies the validity of the Signatories' Signatures in the Envelope. The Signatories must // appear in the same order as the inputs as returned by Tx.GetInputs(). -func (txEnv *Envelope) Verify(getter state.AccountGetter) error { +func (txEnv *Envelope) Verify(getter state.AccountGetter, chainID string) error { err := txEnv.Validate() if err != nil { return err } errPrefix := fmt.Sprintf("could not verify transaction %X", txEnv.Tx.Hash()) + if txEnv.Tx.ChainID != chainID { + return fmt.Errorf("%s: ChainID in envelope is %s but receiving chain has ID %s", + errPrefix, txEnv.Tx.ChainID, chainID) + } inputs := txEnv.Tx.GetInputs() if len(inputs) != len(txEnv.Signatories) { return fmt.Errorf("%s: number of inputs (= %v) should equal number of signatories (= %v)", diff --git a/txs/tx_test.go b/txs/tx_test.go index b3d0d4a41239efbb06f7a83c7db754fea978eecc..9fbc93cb4caa27298aae90fb787d5c7bc49d6d6e 100644 --- a/txs/tx_test.go +++ b/txs/tx_test.go @@ -216,5 +216,5 @@ func testTxSignVerify(t *testing.T, tx payload.Payload) { } txEnv := Enclose(chainID, tx) require.NoError(t, txEnv.Sign(signers...), "Error signing tx: %s", debug.Stack()) - require.NoError(t, txEnv.Verify(nil), "Error verifying tx: %s", debug.Stack()) + require.NoError(t, txEnv.Verify(nil, chainID), "Error verifying tx: %s", debug.Stack()) }