-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands.go
56 lines (42 loc) · 1.52 KB
/
commands.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package walletmanager
import (
"context"
"fmt"
"github.com/iotaledger/evil-tools/pkg/models"
iotago "github.com/iotaledger/iota.go/v4"
)
// CreateAccount creates an implicit account and immediately transition it to a regular account.
func (m *Manager) CreateAccount(ctx context.Context, params *CreateAccountParams) (iotago.AccountID, error) {
if params.Implicit {
return m.createImplicitAccount(ctx, params)
}
return m.createAccountWithFaucet(ctx, params)
}
func (m *Manager) DestroyAccount(ctx context.Context, params *DestroyAccountParams) error {
return m.destroyAccount(ctx, params.AccountAlias)
}
func (m *Manager) ListAccount() error {
m.RLock()
defer m.RUnlock()
hrp := m.API.ProtocolParameters().Bech32HRP()
m.accounts.ForEach(func(alias string, accountData *models.AccountData) bool {
fmt.Printf("----------\n")
fmt.Printf("%-10s %-33s\n", "Alias", alias)
fmt.Printf("%-10s %-33s\n", "AccountID", accountData.Account.Address().AccountID().ToHex())
fmt.Printf("%-10s %-33s\n", "Bech32", accountData.Account.Address().Bech32(hrp))
return true
})
return nil
}
func (m *Manager) AllotToAccount(ctx context.Context, params *AllotAccountParams) error {
return m.allot(ctx, params)
}
func (m *Manager) DelegateToAccount(ctx context.Context, params *DelegateAccountParams) error {
return m.delegateToAccount(ctx, params)
}
func (m *Manager) Claim(ctx context.Context, params *ClaimAccountParams) error {
return m.claim(ctx, params)
}
func (m *Manager) Delegators() []string {
return m.delegations.Keys()
}