-
Notifications
You must be signed in to change notification settings - Fork 644
/
main.go
57 lines (47 loc) · 1.62 KB
/
main.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
57
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package main
import (
"context"
"log"
"time"
"github.com/ava-labs/avalanchego/genesis"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
"github.com/ava-labs/avalanchego/wallet/subnet/primary"
)
func main() {
key := genesis.EWOQKey
uri := primary.LocalAPIURI
kc := secp256k1fx.NewKeychain(key)
subnetIDStr := "29uVeLPJB1eQJkzRemU8g8wZDw5uJRqpab5U2mX9euieVwiEbL"
nodeIDStr := "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg"
subnetID, err := ids.FromString(subnetIDStr)
if err != nil {
log.Fatalf("failed to parse subnet ID: %s\n", err)
}
nodeID, err := ids.NodeIDFromString(nodeIDStr)
if err != nil {
log.Fatalf("failed to parse node ID: %s\n", err)
}
ctx := context.Background()
// NewWalletWithTxs fetches the available UTXOs owned by [kc] on the network
// that [uri] is hosting and registers [subnetID].
walletSyncStartTime := time.Now()
wallet, err := primary.NewWalletWithTxs(ctx, uri, kc, subnetID)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
log.Printf("synced wallet in %s\n", time.Since(walletSyncStartTime))
// Get the P-chain wallet
pWallet := wallet.P()
removeValidatorStartTime := time.Now()
removeValidatorTx, err := pWallet.IssueRemoveSubnetValidatorTx(
nodeID,
subnetID,
)
if err != nil {
log.Fatalf("failed to issue remove subnet validator transaction: %s\n", err)
}
log.Printf("removed subnet validator %s from %s with %s in %s\n", nodeID, subnetID, removeValidatorTx.ID(), time.Since(removeValidatorStartTime))
}