0

I have doubt regarding the newTransaction() function in the transaction.go file in go-ethereum. Why there is no mention of sender's address in the newTransaction() function? From where does it get sender's address?

Here is the code:

func newTransaction(nonce uint64, to common.Address, amount, gasLimit,gasPrice big.Int, data []byte) *Transaction {
    if len(data) > 0 {
       data = common.CopyBytes(data)
    }
    d := txdata{
            AccountNonce: nonce,
            Recipient: to,
            Payload: data,
            Amount: new(big.Int),
            GasLimit: new(big.Int),
            Price: new(big.Int),
            V: new(big.Int),
            R: new(big.Int),
            S: new(big.Int),
    }
    if amount != nil {
        d.Amount.Set(amount)
    }
    if gasLimit != nil {
       d.GasLimit.Set(gasLimit)
    }
    if gasPrice != nil {
       d.Price.Set(gasPrice)
    }

return &Transaction{data: d}
}
1
  • You'd better ask on github than here I think. Jan 11 '18 at 9:09
1

The sender's address is recovered by the receiver from the transaction signature (V, R and S above), and the hash of the transaction data, using the ECDSARECOVER() function. This is in fact how transactions are authenticated - if a valid address results from this, then that is the address of the sender/signer of the transaction.

Details are in the Yellow Paper appendix F.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.