Go-Ethereum Transactions – How to Fix Invalid Sender Error on Private Chain

go-ethereumsignaturetransactions

I created a transaction in Go, signed it with a EIP155Signer signer, but when I try to publish the transaction through the Go client to the private blockchain, I get the error Invalid sender. Any idea what's happening here?

This issue seems to have the same error: https://github.com/ethereum/web3.js/issues/566

The transaction gets signed correctly (string output below), but the From field is never populated, and I'm unable to set it in Go because it's a hidden struct field that is internally set by the EIP155Signer

tx before sign=
    TX(e694193e2f4d6dc099444ff0057456e23cafe0f8035c7c70daf688bc2bf5546a)
    Contract: false
    From:     [invalid sender: invalid sig]
    To:       b424f3bcc3da6f54f27f5f4af0c9c18d567702e6
    Nonce:    0
    GasPrice: 0x0
    GasLimit  0x0
    Value:    0x0
    Data:     0x746865626573746461746165766572
    V:        0x0
    R:        0x0
    S:        0x0
    Hex:      ec80808094b424f3bcc3da6f54f27f5f4af0c9c18d567702e6808f746865626573746461746165766572808080

signed tx=
    TX(ff6c011c7527f74e00fde94f6a4a5e523211f21f221c0b7133bf723486b3284c)
    Contract: false
    From:     [invalid sender: invalid sig]
    To:       b424f3bcc3da6f54f27f5f4af0c9c18d567702e6
    Nonce:    0
    GasPrice: 0x0
    GasLimit  0x0
    Value:    0x0
    Data:     0x746865626573746461746165766572
    V:        0x0
    R:        0x91a89e1ee55cc959572c050780301701c7f02436701db5961ccb01d556c2e708
    S:        0x699559f036a1153b2f979cd01ee9b0beb0e889c8aaab0dbd5a46dd7931842f02
    Hex:      f86c80808094b424f3bcc3da6f54f27f5f4af0c9c18d567702e6808f74686562657374646174616576657280a091a89e1ee55cc959572c050780301701c7f02436701db5961ccb01d556c2e708a0699559f036a1153b2f979cd01ee9b0beb0e889c8aaab0dbd5a46dd7931842f02

Seems that the sender can't be derived according to this source file when the transaction is printed: https://github.com/ethereum/go-ethereum/blob/8771c3061f340451d0966adcc547338a25f2231f/core/types/transaction.go#L273

Best Answer

The issue was that the chain id was not being set correctly. As a result transactions were signed with the incorrect chain id, so the sender could not be derived correctly. The fix was to also declare a config in the genesis block which specified it. An example:

"config": {
    "chainID"       : 10,
    "homesteadBlock": 0,
    "eip155Block":    0,
    "eip158Block":    0
}
Related Topic