wallet: don't allow to ConvertMultisig a locked account

This stretched the definition of Locked somewhat, but still makes sense to
me, locked accounts better not be touched.
This commit is contained in:
Roman Khimov 2022-09-01 16:39:48 +03:00
parent 0090577446
commit 53edbd569f
2 changed files with 9 additions and 0 deletions

View file

@ -205,6 +205,9 @@ func NewAccountFromEncryptedWIF(wif string, pass string, scrypt keys.ScryptParam
// ConvertMultisig sets a's contract to multisig contract with m sufficient signatures.
func (a *Account) ConvertMultisig(m int, pubs []*keys.PublicKey) error {
if a.Locked {
return errors.New("account is locked")
}
var found bool
for i := range pubs {
if bytes.Equal(a.publicKey, pubs[i].Bytes()) {

View file

@ -179,6 +179,12 @@ func TestAccount_ConvertMultisig(t *testing.T) {
"03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699",
}
t.Run("locked", func(t *testing.T) {
a.Locked = true
pubs := convertPubs(t, hexs)
require.Error(t, a.ConvertMultisig(1, pubs))
a.Locked = false
})
t.Run("invalid number of signatures", func(t *testing.T) {
pubs := convertPubs(t, hexs)
require.Error(t, a.ConvertMultisig(0, pubs))