Skip to content

Commit

Permalink
Merge pull request #14 from danceratopz/t8n-server-use-v-to-determine…
Browse files Browse the repository at this point in the history
…-if-tx-is-playback-protected

Use v to determine if the transaction is protected

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
  • Loading branch information
shemnon committed Jul 18, 2023
1 parent 22652c5 commit a9871dd
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ protected static List<Transaction> extractTransactions(
if (txNode.has("to")) {
builder.to(Address.fromHexString(txNode.get("to").textValue()));
}

if (transactionType.requiresChainId()
|| (txNode.has("protected") && txNode.get("protected").asBoolean(false))) {
BigInteger v =
Bytes.fromHexStringLenient(txNode.get("v").textValue()).toUnsignedBigInteger();
if (transactionType.requiresChainId() || (v.compareTo(REPLAY_PROTECTED_V_MIN) > 0)) {
// chainid if protected
builder.chainId(chainId);
}
Expand Down Expand Up @@ -191,14 +191,11 @@ protected static List<Transaction> extractTransactions(

transactions.add(builder.signAndBuild(keys));
} else {
BigInteger v =
Bytes.fromHexStringLenient(txNode.get("v").textValue()).toUnsignedBigInteger();
if (transactionType == TransactionType.FRONTIER) {
if (v.compareTo(REPLAY_PROTECTED_V_MIN) > 0) {
v =
v.subtract(REPLAY_PROTECTED_V_BASE)
.subtract(chainId.multiply(BigInteger.TWO));
builder.chainId(chainId);
} else {
v = v.subtract(REPLAY_UNPROTECTED_V_BASE);
}
Expand Down

0 comments on commit a9871dd

Please sign in to comment.