diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-08-01 23:47:32 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-08-01 23:47:32 +0800 |
commit | a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3 (patch) | |
tree | 511d91e35f58322824bd187e5363f0d420f6e5b4 /xeth/xeth.go | |
parent | ab85a3593a66817eae1ada79ec6dee62891c4360 (diff) | |
parent | 81e2124ea20503b70fac726868e3bbefd8c02d73 (diff) | |
download | go-tangerine-a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3.tar go-tangerine-a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3.tar.gz go-tangerine-a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3.tar.bz2 go-tangerine-a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3.tar.lz go-tangerine-a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3.tar.xz go-tangerine-a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3.tar.zst go-tangerine-a8b39b5cc0dff46e5834826fac6f37e39ee4c3b3.zip |
Merge pull request #1541 from bas-vk/issue1518
Improved error handling for NewTransactionFromBytes
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r-- | xeth/xeth.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go index 63826a334..5d54c1f7e 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -310,7 +310,12 @@ func (self *XEth) EthTransactionByHash(hash string) (tx *types.Transaction, blha // some chain, this probably needs to be refactored for more expressiveness data, _ := self.backend.ExtraDb().Get(common.FromHex(hash)) if len(data) != 0 { - tx = types.NewTransactionFromBytes(data) + dtx := new(types.Transaction) + if err := rlp.DecodeBytes(data, dtx); err != nil { + glog.V(logger.Error).Infoln(err) + return + } + tx = dtx } else { // check pending transactions tx = self.backend.TxPool().GetTransaction(common.HexToHash(hash)) } @@ -773,8 +778,14 @@ func (self *XEth) FromNumber(str string) string { } func (self *XEth) PushTx(encodedTx string) (string, error) { - tx := types.NewTransactionFromBytes(common.FromHex(encodedTx)) - err := self.backend.TxPool().Add(tx) + tx := new(types.Transaction) + err := rlp.DecodeBytes(common.FromHex(encodedTx), tx) + if err != nil { + glog.V(logger.Error).Infoln(err) + return "", err + } + + err = self.backend.TxPool().Add(tx) if err != nil { return "", err } |