Skip to content

Commit

Permalink
Simplify Transaction interface
Browse files Browse the repository at this point in the history
Remove rlpEncode(final long chainId) method override

This is to make the upcoming changes to the serialize method easier
  • Loading branch information
siladu committed Jul 10, 2023
1 parent 9df4ef8 commit fdede82
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ void ensureSignaturesCreatedHavePositiveValues() {
// transaction being signed with a given key, resulted in the transaction being rejected by
// Besu due to "INVALID SIGNATURE" - ultimately, it was came down to byte[] --> BigInt resulting
// in negative value.
final long chainId = 44844;

final EthSendTransactionJsonParameters txnParams =
new EthSendTransactionJsonParameters("0xf17f52151ebef6c7334fad080c5704d77216b732");
txnParams.gasPrice("0x0");
Expand All @@ -42,7 +40,7 @@ void ensureSignaturesCreatedHavePositiveValues() {
txnParams.receiver("0x627306090abaB3A6e1400e9345bC60c78a8BEf57");

final EthTransaction txn = new EthTransaction(1337L, txnParams, null, null);
final byte[] serialisedBytes = txn.rlpEncode(chainId);
final byte[] serialisedBytes = txn.rlpEncode(null);

final CredentialSigner signer =
new CredentialSigner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public interface Transaction {

byte[] rlpEncode(SignatureData signatureData);

default byte[] rlpEncode(final long chainId) {
final SignatureData signatureData =
new SignatureData(longToBytes(chainId), new byte[] {}, new byte[] {});
return rlpEncode(signatureData);
}

boolean isNonceUserSpecified();

String sender();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package tech.pegasys.web3signer.core.service.jsonrpc.handlers.signing;

import static tech.pegasys.web3signer.core.service.jsonrpc.handlers.sendtransaction.transaction.Transaction.longToBytes;
import static tech.pegasys.web3signer.core.service.jsonrpc.response.JsonRpcError.SIGNING_FROM_IS_NOT_AN_UNLOCKED_ACCOUNT;
import static tech.pegasys.web3signer.core.util.Eth1AddressUtil.signerPublicKeyFromAddress;

Expand Down Expand Up @@ -42,7 +43,9 @@ public TransactionSerializer(final ArtifactSignerProvider signer, final long cha
}

public String serialize(final Transaction transaction) {
final byte[] bytesToSign = transaction.rlpEncode(chainId);
final SignatureData signatureData =
new SignatureData(longToBytes(chainId), new byte[] {}, new byte[] {});
final byte[] bytesToSign = transaction.rlpEncode(signatureData);

Optional<String> publicKey = signerPublicKeyFromAddress(signer, transaction.sender());

Expand Down

0 comments on commit fdede82

Please sign in to comment.