Skip to content

Commit

Permalink
Check tx signature in sendRawTransactionAction
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Mar 31, 2021
1 parent f017fa4 commit 6262f8e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ export class TxPool {
try {
return tx.getSenderAddress(); // verifies signature
} catch (e) {
throw new InvalidInputError("Invalid Signature");
if (!tx.isSigned()) {
throw new InvalidInputError("Invalid Signature");
}

throw new InvalidInputError(e.message);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,10 @@ export class EthModule {
throw error;
}

if (!tx.isSigned()) {
throw new InvalidInputError("Invalid Signature");
}

return this._sendTransactionAndReturnHash(tx);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ export class HardhatNode extends EventEmitter {
try {
sender = tx.getSenderAddress(); // verifies signature as a side effect
} catch (e) {
throw new InvalidInputError("Invalid Signature");
throw new InvalidInputError(e.message);
}

const senderNonce = await this._txPool.getExecutableNonce(sender);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3542,7 +3542,6 @@ describe("Eth module", function () {
// This transaction was obtained with eth_sendTransaction, and its r value was wiped
"0xf3808501dcd6500083015f9080800082011a80a00dbd1a45b7823be518540ca77afb7178a470b8054281530a6cdfd0ad3328cf96",
],
// A missing `r` is now treated as unsigned, via the BaseTransaction method "isSigned"
"Invalid Signature"
);
});
Expand Down

0 comments on commit 6262f8e

Please sign in to comment.