Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

hw-app-eth: signTransaction different address than given path #436

Closed
picatextra opened this issue Jan 3, 2020 · 2 comments
Closed

hw-app-eth: signTransaction different address than given path #436

picatextra opened this issue Jan 3, 2020 · 2 comments

Comments

@picatextra
Copy link

When decoding the raw transaction , the from value is different than the address of the given path .
Resulting in an error when calling web3.eth.sendSignedTransaction
(Returned error: insufficient funds for gas * price + value)
Because the signed address is else.

const txParams = {
    gasPrice: price,
    gasLimit: limit,
    to: ADDR,
    data : data1,
    value: '0x00',
    nonce: web3.utils.toHex(count)
};
const txHex = new Transaction(txParams).serialize().toString("hex");
const result = await appeth.signTransaction("44'/60'/0'/0/0", txHex);

txParams.r = '0x'+result.r;
txParams.s = '0x'+result.s;
txParams.v = '0x'+result.v;
const tx2 = new Transaction(txParams);

var serializedTx = '0x' + tx2.serialize().toString('hex');
let sender  =    web3.eth.accounts.recoverTransaction(serializedTx);
@Git-on-my-level
Copy link

Hey @picatextra how did you fix this? I'm running into the same issue. Any insight would be helpful!

@Git-on-my-level
Copy link

I solved this by setting the EIP155 bits

// Set the EIP155 bits

https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md

// Set the EIP155 bits
tx.raw[6] = Buffer.from([networkId]); // v
tx.raw[7] = Buffer.from([]); // r
tx.raw[8] = Buffer.from([]); // s

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants