diff options
author | ligi <ligi@ligi.de> | 2017-07-17 19:31:26 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-07-17 19:31:26 +0800 |
commit | cf5d4b55412f570bd1b492998b0c0b8e953e2418 (patch) | |
tree | 79c53dd65e4676d58cfffc5c8839a92f628385bd /mobile | |
parent | b95c2b58f0f41426b3667a20db0efff77a7e6c4e (diff) | |
download | dexon-cf5d4b55412f570bd1b492998b0c0b8e953e2418.tar dexon-cf5d4b55412f570bd1b492998b0c0b8e953e2418.tar.gz dexon-cf5d4b55412f570bd1b492998b0c0b8e953e2418.tar.bz2 dexon-cf5d4b55412f570bd1b492998b0c0b8e953e2418.tar.lz dexon-cf5d4b55412f570bd1b492998b0c0b8e953e2418.tar.xz dexon-cf5d4b55412f570bd1b492998b0c0b8e953e2418.tar.zst dexon-cf5d4b55412f570bd1b492998b0c0b8e953e2418.zip |
mobile: use EIP155 signer (#14817)
* mobile: Use EIP155Signer - closes #14762
* mobile: Correctly fall back on HomesteadSigner when no chainID is passed in
Diffstat (limited to 'mobile')
-rw-r--r-- | mobile/types.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/mobile/types.go b/mobile/types.go index 02282f7a3..4c4cd8822 100644 --- a/mobile/types.go +++ b/mobile/types.go @@ -265,10 +265,11 @@ func (tx *Transaction) GetSigHash() *Hash { return &Hash{tx.tx.SigHash(types.Hom func (tx *Transaction) GetCost() *BigInt { return &BigInt{tx.tx.Cost()} } func (tx *Transaction) GetFrom(chainID *BigInt) (address *Address, _ error) { - if chainID == nil { // Null passed from mobile app - chainID = new(BigInt) + var signer types.Signer = types.HomesteadSigner{} + if chainID != nil { + signer = types.NewEIP155Signer(chainID.bigint) } - from, err := types.Sender(types.NewEIP155Signer(chainID.bigint), tx.tx) + from, err := types.Sender(signer, tx.tx) return &Address{from}, err } @@ -279,8 +280,12 @@ func (tx *Transaction) GetTo() *Address { return nil } -func (tx *Transaction) WithSignature(sig []byte) (signedTx *Transaction, _ error) { - rawTx, err := tx.tx.WithSignature(types.HomesteadSigner{}, sig) +func (tx *Transaction) WithSignature(sig []byte, chainID *BigInt) (signedTx *Transaction, _ error) { + var signer types.Signer = types.HomesteadSigner{} + if chainID != nil { + signer = types.NewEIP155Signer(chainID.bigint) + } + rawTx, err := tx.tx.WithSignature(signer, sig) return &Transaction{rawTx}, err } |