ethclient, mobile: add TransactionSender (#15127)

* core/types: make Signer derive address instead of public key

There are two reasons to do this now: The upcoming ethclient signer
doesn't know the public key, just the address. EIP 208 will introduce a
new signer which derives the 'entry point' address for transactions with
zero signature. The entry point has no public key.

Other changes to the interface ease the path make to moving signature
crypto out of core/types later.

* ethclient, mobile: add TransactionSender

The new method can get the right signer without any crypto, and without
knowledge of the signature scheme that was used when the transaction was
included.
This commit is contained in:
Felix Lange
2017-10-01 11:03:28 +02:00
committed by GitHub
parent a660685746
commit d78ad226c2
7 changed files with 204 additions and 149 deletions

View File

@ -77,6 +77,13 @@ func (ec *EthereumClient) GetTransactionByHash(ctx *Context, hash *Hash) (tx *Tr
return &Transaction{rawTx}, err
}
// GetTransactionSender returns the sender address of a transaction. The transaction must
// be included in blockchain at the given block and index.
func (ec *EthereumClient) GetTransactionSender(ctx *Context, tx *Transaction, blockhash *Hash, index int) (sender *Address, _ error) {
addr, err := ec.client.TransactionSender(ctx.context, tx.tx, blockhash.hash, uint(index))
return &Address{addr}, err
}
// GetTransactionCount returns the total number of transactions in the given block.
func (ec *EthereumClient) GetTransactionCount(ctx *Context, hash *Hash) (count int, _ error) {
rawCount, err := ec.client.TransactionCount(ctx.context, hash.hash)