diff --git a/pkg/services/rpcsrv/client_test.go b/pkg/services/rpcsrv/client_test.go index ec3a6b70d..5315c8f16 100644 --- a/pkg/services/rpcsrv/client_test.go +++ b/pkg/services/rpcsrv/client_test.go @@ -850,7 +850,6 @@ func TestSignAndPushInvocationTx(t *testing.T) { Parameters: []wallet.ContractParam{}, Deployed: true, }, - Locked: true, Default: false, } @@ -866,7 +865,6 @@ func TestSignAndPushInvocationTx(t *testing.T) { }, Deployed: true, }, - Locked: true, Default: false, } diff --git a/pkg/wallet/account.go b/pkg/wallet/account.go index 335beba72..946ea4335 100644 --- a/pkg/wallet/account.go +++ b/pkg/wallet/account.go @@ -90,6 +90,9 @@ func (a *Account) SignTx(net netmode.Magic, t *transaction.Transaction) error { accHash util.Uint160 err error ) + if a.Locked { + return errors.New("account is locked") + } if a.Contract == nil { return errors.New("account has no contract") } @@ -119,7 +122,7 @@ func (a *Account) SignTx(net netmode.Magic, t *transaction.Transaction) error { return nil } if a.privateKey == nil { - return errors.New("account is not unlocked") + return errors.New("account key is not available (need to decrypt?)") } sign := a.privateKey.SignHashable(uint32(net), t) diff --git a/pkg/wallet/account_test.go b/pkg/wallet/account_test.go index 1e328a857..eeaa9a3f8 100644 --- a/pkg/wallet/account_test.go +++ b/pkg/wallet/account_test.go @@ -134,6 +134,10 @@ func TestContractSignTx(t *testing.T) { require.Equal(t, 1, len(tx.Scripts)) require.Equal(t, 66, len(tx.Scripts[0].InvocationScript)) + acc2.Locked = true + require.Error(t, acc2.SignTx(0, tx)) // Locked account. + + acc2.Locked = false acc2.privateKey = nil require.Error(t, acc2.SignTx(0, tx)) // No private key.