wallet: implement (*Account).SignTx

It is used in both CLI and RPC.
This commit is contained in:
Evgenii Stratonikov 2020-02-28 19:01:07 +03:00
parent 6541bd4d42
commit 05a3625b7d
6 changed files with 44 additions and 50 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/CityOfZion/neo-go/pkg/rpc/response/result"
"github.com/CityOfZion/neo-go/pkg/smartcontract"
"github.com/CityOfZion/neo-go/pkg/util"
"github.com/CityOfZion/neo-go/pkg/wallet"
"github.com/pkg/errors"
)
@ -179,7 +180,10 @@ func (c *Client) SignAndPushInvocationTx(script []byte, wif *keys.WIF, gas util.
}
}
if err = request.SignTx(tx, wif); err != nil {
acc, err := wallet.NewAccountFromWIF(wif.S)
if err != nil {
return txHash, err
} else if err = acc.SignTx(tx); err != nil {
return txHash, errors.Wrap(err, "failed to sign tx")
}
txHash = tx.Hash()