diff --git a/VERSION b/VERSION index 8446488ff..91d98abbb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.64.4 +0.64.5 diff --git a/multiaccounts/accounts/account_test.go b/multiaccounts/accounts/account_test.go new file mode 100644 index 000000000..553ae3e7f --- /dev/null +++ b/multiaccounts/accounts/account_test.go @@ -0,0 +1,35 @@ +package accounts + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestIsOwnAccount(t *testing.T) { + account := Account{Wallet: true} + require.True(t, account.IsOwnAccount()) + + account = Account{ + Type: accountTypeGenerated, + } + require.True(t, account.IsOwnAccount()) + + account = Account{ + Type: accountTypeKey, + } + require.True(t, account.IsOwnAccount()) + + account = Account{ + Type: accountTypeSeed, + } + require.True(t, account.IsOwnAccount()) + + account = Account{ + Type: accountTypeWatch, + } + require.False(t, account.IsOwnAccount()) + + account = Account{} + require.False(t, account.IsOwnAccount()) +} diff --git a/multiaccounts/accounts/database.go b/multiaccounts/accounts/database.go index 87ad15ffb..6b1cecf16 100644 --- a/multiaccounts/accounts/database.go +++ b/multiaccounts/accounts/database.go @@ -36,6 +36,20 @@ type Account struct { Color string `json:"color"` } +const ( + accountTypeGenerated = "generated" + accountTypeKey = "key" + accountTypeSeed = "seed" + accountTypeWatch = "watch" +) + +// IsOwnAccount returns true if this is an account we have the private key for +// NOTE: Wallet flag can't be used as it actually indicates that it's the default +// Wallet +func (a *Account) IsOwnAccount() bool { + return a.Wallet || a.Type == accountTypeSeed || a.Type == accountTypeGenerated || a.Type == accountTypeKey +} + type Settings struct { // required Address types.Address `json:"address"` diff --git a/services/ext/service.go b/services/ext/service.go index a288d1051..701b0e3fa 100644 --- a/services/ext/service.go +++ b/services/ext/service.go @@ -313,7 +313,7 @@ func (s *Service) verifyTransactionLoop(tick time.Duration, cancel <-chan struct } var wallets []types.Address for _, account := range accounts { - if account.Wallet { + if account.IsOwnAccount() { wallets = append(wallets, types.BytesToAddress(account.Address.Bytes())) } }