mirror of
https://github.com/status-im/status-go.git
synced 2025-01-11 15:14:52 +00:00
Use IsOwnAccount instead of Wallet when watching for transactions
There was an issue in using the `Wallet` flag when checking accounts to watch for transactions. `Wallet` indicates that it's the default wallet, not whether is a wallet account. That can only be checked by looking at the type (and the `Wallet` flag). If the type is `generated`, `key` or `seed` it should be watched for transactions.
This commit is contained in:
parent
0b2bd2863b
commit
d65946e9c0
2
VERSION
2
VERSION
@ -1 +1 @@
|
|||||||
0.64.4
|
0.64.5
|
||||||
|
35
multiaccounts/accounts/account_test.go
Normal file
35
multiaccounts/accounts/account_test.go
Normal file
@ -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())
|
||||||
|
}
|
@ -36,6 +36,20 @@ type Account struct {
|
|||||||
Color string `json:"color"`
|
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 {
|
type Settings struct {
|
||||||
// required
|
// required
|
||||||
Address types.Address `json:"address"`
|
Address types.Address `json:"address"`
|
||||||
|
@ -313,7 +313,7 @@ func (s *Service) verifyTransactionLoop(tick time.Duration, cancel <-chan struct
|
|||||||
}
|
}
|
||||||
var wallets []types.Address
|
var wallets []types.Address
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
if account.Wallet {
|
if account.IsOwnAccount() {
|
||||||
wallets = append(wallets, types.BytesToAddress(account.Address.Bytes()))
|
wallets = append(wallets, types.BytesToAddress(account.Address.Bytes()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user