From f058a19d513221b8269de62fb437ab922c01d63a Mon Sep 17 00:00:00 2001 From: Michele Esposito <34438276+mikesposito@users.noreply.github.com> Date: Sat, 2 Dec 2023 11:08:12 +0100 Subject: [PATCH] fix: invalid rlp data for legacy transactions (#212) --- src/ledger-keyring.test.ts | 4 +++- src/ledger-keyring.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ledger-keyring.test.ts b/src/ledger-keyring.test.ts index f457001f..5c0ca773 100644 --- a/src/ledger-keyring.test.ts +++ b/src/ledger-keyring.test.ts @@ -545,7 +545,9 @@ describe('LedgerKeyring', function () { .mockImplementation(async (params) => { expect(params).toStrictEqual({ hdPath: "m/44'/60'/0'/0", - tx: RLP.encode(newFakeTx.getMessageToSign(false)).toString(), + tx: Buffer.from( + RLP.encode(newFakeTx.getMessageToSign(false)), + ).toString('hex'), }); return expectedRSV; }); diff --git a/src/ledger-keyring.ts b/src/ledger-keyring.ts index 77392c5b..08bd6103 100644 --- a/src/ledger-keyring.ts +++ b/src/ledger-keyring.ts @@ -340,7 +340,7 @@ export class LedgerKeyring extends EventEmitter { rawTxHex = Buffer.isBuffer(messageToSign) ? messageToSign.toString('hex') - : RLP.encode(messageToSign).toString(); + : Buffer.from(RLP.encode(messageToSign)).toString('hex'); return this.#signTransaction(address, rawTxHex, (payload) => { // Because tx will be immutable, first get a plain javascript object that