mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
cli/wallet: fail if signer is missing in tx
This commit is contained in:
parent
7553c1ac96
commit
8a4b97171a
2 changed files with 26 additions and 0 deletions
|
@ -75,6 +75,21 @@ func TestSignMultisigTx(t *testing.T) {
|
|||
"--to", priv.Address(), "--token", "NEO", "--amount", "1",
|
||||
"--out", txPath)
|
||||
|
||||
simplePriv, err := keys.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
{ // Simple signer, not in signers.
|
||||
e.In.WriteString("acc\rpass\rpass\r")
|
||||
e.Run(t, "neo-go", "wallet", "import",
|
||||
"--wallet", wallet1Path,
|
||||
"--wif", simplePriv.WIF())
|
||||
t.Run("sign with missing signer", func(t *testing.T) {
|
||||
e.In.WriteString("pass\r")
|
||||
e.RunWithError(t, "neo-go", "wallet", "sign",
|
||||
"--wallet", wallet1Path, "--address", simplePriv.Address(),
|
||||
"--in", txPath, "--out", txPath)
|
||||
})
|
||||
}
|
||||
|
||||
e.In.WriteString("pass\r")
|
||||
e.Run(t, "neo-go", "wallet", "sign",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
|
|
|
@ -36,6 +36,17 @@ func signStoredTransaction(ctx *cli.Context) error {
|
|||
return cli.NewExitError("verifiable item is not a transaction", 1)
|
||||
}
|
||||
|
||||
signerFound := false
|
||||
for i := range tx.Signers {
|
||||
if tx.Signers[i].Account == acc.Contract.ScriptHash() {
|
||||
signerFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !signerFound {
|
||||
return cli.NewExitError("tx signers don't contain provided account", 1)
|
||||
}
|
||||
|
||||
priv := acc.PrivateKey()
|
||||
sign := priv.Sign(tx.GetSignedPart())
|
||||
if err := c.AddSignature(acc.Contract, priv.PublicKey(), sign); err != nil {
|
||||
|
|
Loading…
Reference in a new issue