Merge pull request #2485 from nspcc-dev/fix-rpc

rpc: check transaction for validness before network fee calculation
This commit is contained in:
Roman Khimov 2022-05-17 11:34:11 +03:00 committed by GitHub
commit 711112ae40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 5 deletions

View file

@ -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))

View file

@ -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) {