transaction: implement AddVerificationHash() method
This commit is contained in:
parent
ca476cbf8a
commit
cdf025bf89
4 changed files with 11 additions and 14 deletions
|
@ -311,10 +311,7 @@ func transferNEP5(ctx *cli.Context) error {
|
||||||
|
|
||||||
gas := flags.Fixed8FromContext(ctx, "gas")
|
gas := flags.Fixed8FromContext(ctx, "gas")
|
||||||
tx := transaction.NewInvocationTX(w.Bytes(), gas)
|
tx := transaction.NewInvocationTX(w.Bytes(), gas)
|
||||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{
|
tx.AddVerificationHash(from)
|
||||||
Usage: transaction.Script,
|
|
||||||
Data: from.BytesBE(),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err := request.AddInputsAndUnspentsToTx(tx, fromFlag.String(), core.UtilityTokenID(), gas, c); err != nil {
|
if err := request.AddInputsAndUnspentsToTx(tx, fromFlag.String(), core.UtilityTokenID(), gas, c); err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("can't add GAS to a tx: %v", err), 1)
|
return cli.NewExitError(fmt.Errorf("can't add GAS to a tx: %v", err), 1)
|
||||||
|
|
|
@ -91,6 +91,14 @@ func (t *Transaction) AddInput(in *Input) {
|
||||||
t.Inputs = append(t.Inputs, *in)
|
t.Inputs = append(t.Inputs, *in)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddVerificationHash adds a script attribute for transaction verification.
|
||||||
|
func (t *Transaction) AddVerificationHash(addr util.Uint160) {
|
||||||
|
t.Attributes = append(t.Attributes, Attribute{
|
||||||
|
Usage: Script,
|
||||||
|
Data: addr.BytesBE(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
||||||
t.Type = TXType(br.ReadB())
|
t.Type = TXType(br.ReadB())
|
||||||
|
|
|
@ -515,11 +515,7 @@ func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sys
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return txHash, errors.Wrap(err, "failed to get address")
|
return txHash, errors.Wrap(err, "failed to get address")
|
||||||
}
|
}
|
||||||
tx.Attributes = append(tx.Attributes,
|
tx.AddVerificationHash(addr)
|
||||||
transaction.Attribute{
|
|
||||||
Usage: transaction.Script,
|
|
||||||
Data: addr.BytesBE(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = acc.SignTx(tx); err != nil {
|
if err = acc.SignTx(tx); err != nil {
|
||||||
|
|
|
@ -38,11 +38,7 @@ func CreateRawContractTransaction(params ContractTxParams) (*transaction.Transac
|
||||||
if toAddressHash, err = address.StringToUint160(toAddress); err != nil {
|
if toAddressHash, err = address.StringToUint160(toAddress); err != nil {
|
||||||
return nil, errs.Wrapf(err, "Failed to take script hash from address: %v", toAddress)
|
return nil, errs.Wrapf(err, "Failed to take script hash from address: %v", toAddress)
|
||||||
}
|
}
|
||||||
tx.Attributes = append(tx.Attributes,
|
tx.AddVerificationHash(fromAddressHash)
|
||||||
transaction.Attribute{
|
|
||||||
Usage: transaction.Script,
|
|
||||||
Data: fromAddressHash.BytesBE(),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err = AddInputsAndUnspentsToTx(tx, fromAddress, assetID, amount, balancer); err != nil {
|
if err = AddInputsAndUnspentsToTx(tx, fromAddress, assetID, amount, balancer); err != nil {
|
||||||
return nil, errs.Wrap(err, "failed to add inputs and unspents to transaction")
|
return nil, errs.Wrap(err, "failed to add inputs and unspents to transaction")
|
||||||
|
|
Loading…
Reference in a new issue