Merge pull request #2485 from nspcc-dev/fix-rpc
rpc: check transaction for validness before network fee calculation
This commit is contained in:
commit
711112ae40
2 changed files with 1 additions and 5 deletions
|
@ -226,10 +226,6 @@ func (t *Transaction) EncodeBinary(bw *io.BinWriter) {
|
|||
// encodeHashableFields encodes the fields that are not used for
|
||||
// signing the transaction, which are all fields except the scripts.
|
||||
func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
||||
if len(t.Script) == 0 {
|
||||
bw.Err = errors.New("transaction has no script")
|
||||
return
|
||||
}
|
||||
bw.WriteB(byte(t.Version))
|
||||
bw.WriteU32LE(t.Nonce)
|
||||
bw.WriteU64LE(uint64(t.SystemFee))
|
||||
|
|
|
@ -109,7 +109,7 @@ func TestNewTransactionFromBytes(t *testing.T) {
|
|||
|
||||
func TestEncodingTXWithNoScript(t *testing.T) {
|
||||
_, err := testserdes.EncodeBinary(new(Transaction))
|
||||
require.Error(t, err)
|
||||
require.NoError(t, err) // Garbage in -> garbage out.
|
||||
}
|
||||
|
||||
func TestDecodingTXWithNoScript(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue