Search code examples
ethereumgeth

Can a geth node return a signature of a transaction via JSON RPC?


I'm looking for a JSON RPC endpoint that takes an address and the hash of a transaction and returns the signature of that hash.

For context: I have a geth node that imported a private key, but the problem is this geth node often get out of sync, and can't send out a signed transaction.

When it's out of sync, if I call the eth_sendTransaction JSON RPC endpoint, it still returns a transaction hash as if it has signed and sent it, but since it's out of sync, the signed transaction seems stuck and ever gets minded.

I'm thinking, since the geth node has imported the private key, it should be able to sign a transaction, and then I can take the signature to assemble a payload as a signed transaction to send to any geth node (i.e, infura nodes) via eth_sendRawTransaction.

I found the eth_sign JSON RPC endpoint, but it can only sign message instead of transactions.

Is there a way or a JSON RPC endpoint to return a signature of a transaction? I can't find it in the document


Solution

  • Geth and Parity both implement an eth_signTransaction JSON-RPC method. https://github.com/ethereum/EIPs/issues/728 proposes to standardize and document that, but if you're using geth, you can use it already.