core: add NewTransactionFromBytes method to Transaction
Added `NewTransactionFromBytes(b []byte)` method to transaction.Transaction in order to avoid code duplication.
This commit is contained in:
parent
5a22651e36
commit
d1f92a585b
4 changed files with 18 additions and 12 deletions
|
@ -931,10 +931,8 @@ func (s *Server) sendrawtransaction(reqParams request.Params) (interface{}, erro
|
|||
} else if byteTx, err := reqParams[0].GetBytesHex(); err != nil {
|
||||
return nil, response.ErrInvalidParams
|
||||
} else {
|
||||
r := io.NewBinReaderFromBuf(byteTx)
|
||||
tx := &transaction.Transaction{}
|
||||
tx.DecodeBinary(r)
|
||||
if r.Err != nil {
|
||||
tx, err := transaction.NewTransactionFromBytes(byteTx)
|
||||
if err != nil {
|
||||
return nil, response.ErrInvalidParams
|
||||
}
|
||||
relayReason := s.coreServer.RelayTxn(tx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue