forked from TrueCloudLab/neoneo-go
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:
parent
0090577446
commit
53edbd569f
2 changed files with 9 additions and 0 deletions
|
@ -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.
|
// ConvertMultisig sets a's contract to multisig contract with m sufficient signatures.
|
||||||
func (a *Account) ConvertMultisig(m int, pubs []*keys.PublicKey) error {
|
func (a *Account) ConvertMultisig(m int, pubs []*keys.PublicKey) error {
|
||||||
|
if a.Locked {
|
||||||
|
return errors.New("account is locked")
|
||||||
|
}
|
||||||
var found bool
|
var found bool
|
||||||
for i := range pubs {
|
for i := range pubs {
|
||||||
if bytes.Equal(a.publicKey, pubs[i].Bytes()) {
|
if bytes.Equal(a.publicKey, pubs[i].Bytes()) {
|
||||||
|
|
|
@ -179,6 +179,12 @@ func TestAccount_ConvertMultisig(t *testing.T) {
|
||||||
"03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699",
|
"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) {
|
t.Run("invalid number of signatures", func(t *testing.T) {
|
||||||
pubs := convertPubs(t, hexs)
|
pubs := convertPubs(t, hexs)
|
||||||
require.Error(t, a.ConvertMultisig(0, pubs))
|
require.Error(t, a.ConvertMultisig(0, pubs))
|
||||||
|
|
Loading…
Reference in a new issue