transaction: marshal ContractTX even if Data is nil
It contains no information so it doesn't matter anyway.
This commit is contained in:
parent
634e9483d3
commit
7eaeb18f18
2 changed files with 5 additions and 3 deletions
|
@ -416,7 +416,6 @@ func transferAsset(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := transaction.NewContractTX()
|
tx := transaction.NewContractTX()
|
||||||
tx.Data = new(transaction.ContractTX)
|
|
||||||
if err := request.AddInputsAndUnspentsToTx(tx, from, asset, amount, c); err != nil {
|
if err := request.AddInputsAndUnspentsToTx(tx, from, asset, amount, c); err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,8 @@ func (t *Transaction) EncodeBinary(bw *io.BinWriter) {
|
||||||
// encodeHashableFields encodes the fields that are not used for
|
// encodeHashableFields encodes the fields that are not used for
|
||||||
// signing the transaction, which are all fields except the scripts.
|
// signing the transaction, which are all fields except the scripts.
|
||||||
func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
||||||
if t.Data == nil {
|
noData := t.Type == ContractType
|
||||||
|
if t.Data == nil && !noData {
|
||||||
bw.Err = errors.New("transaction has no data")
|
bw.Err = errors.New("transaction has no data")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -166,7 +167,9 @@ func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
||||||
bw.WriteB(byte(t.Version))
|
bw.WriteB(byte(t.Version))
|
||||||
|
|
||||||
// Underlying TXer.
|
// Underlying TXer.
|
||||||
t.Data.EncodeBinary(bw)
|
if !noData {
|
||||||
|
t.Data.EncodeBinary(bw)
|
||||||
|
}
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
bw.WriteArray(t.Attributes)
|
bw.WriteArray(t.Attributes)
|
||||||
|
|
Loading…
Reference in a new issue