From 1880e96844ac0962daf49f5ff9503928fa15a73b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 6 Jul 2020 10:01:14 +0300 Subject: [PATCH] cli: fix contract deploy&invoke We should add cosigners to deplyment and invocation transactions. --- cli/smartcontract/smart_contract.go | 4 ++-- pkg/rpc/client/rpc.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index a1575755b..10ca9c2cf 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -460,7 +460,7 @@ func invokeInternal(ctx *cli.Context, signAndPush bool) error { if err != nil { return cli.NewExitError(fmt.Errorf("bad script returned from the RPC node: %v", err), 1) } - txHash, err := c.SignAndPushInvocationTx(script, acc, 0, gas) + txHash, err := c.SignAndPushInvocationTx(script, acc, 0, gas, cosigners) if err != nil { return cli.NewExitError(fmt.Errorf("failed to push invocation tx: %v", err), 1) } @@ -665,7 +665,7 @@ func contractDeploy(ctx *cli.Context) error { return cli.NewExitError(fmt.Errorf("failed to test-invoke deployment script: %v", err), 1) } - txHash, err := c.SignAndPushInvocationTx(txScript, acc, invRes.GasConsumed, gas) + txHash, err := c.SignAndPushInvocationTx(txScript, acc, invRes.GasConsumed, gas, nil) if err != nil { return cli.NewExitError(fmt.Errorf("failed to push invocation tx: %v", err), 1) } diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index 7aac5ff41..0bb161b96 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -429,12 +429,13 @@ func (c *Client) SubmitBlock(b block.Block) error { // SignAndPushInvocationTx signs and pushes given script as an invocation // transaction using given wif to sign it and spending the amount of gas // specified. It returns a hash of the invocation transaction and an error. -func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sysfee int64, netfee util.Fixed8) (util.Uint256, error) { +func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sysfee int64, netfee util.Fixed8, cosigners []transaction.Cosigner) (util.Uint256, error) { var txHash util.Uint256 var err error tx := transaction.New(c.opts.Network, script, sysfee) tx.SystemFee = sysfee + tx.Cosigners = cosigners validUntilBlock, err := c.CalculateValidUntilBlock() if err != nil {