generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathadmin_add_user.go
39 lines (34 loc) · 1.13 KB
/
admin_add_user.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
package main
import (
"context"
"log"
wallet "github.com/bitcoin-sv/spv-wallet-go-client"
"github.com/bitcoin-sv/spv-wallet-go-client/commands"
"github.com/bitcoin-sv/spv-wallet-go-client/examples"
"github.com/bitcoin-sv/spv-wallet-go-client/examples/exampleutil"
"github.com/bitcoin-sv/spv-wallet-go-client/internal/api/v1/queryparams"
)
func main() {
adminAPI, err := wallet.NewAdminAPIWithXPub(exampleutil.NewDefaultConfig(), examples.AdminXPriv)
if err != nil {
log.Fatalf("Failed to initialize admin API with XPriv: %v", err)
}
ctx := context.Background()
xPub, err := adminAPI.CreateXPub(ctx, &commands.CreateUserXpub{
XPub: examples.UserXPub,
Metadata: queryparams.Metadata{"key": "value"},
})
if err != nil {
log.Fatalf("Failed to create xPub: %v", err)
}
exampleutil.PrettyPrint("Created XPub", xPub)
paymail, err := adminAPI.CreatePaymail(ctx, &commands.CreatePaymail{
Metadata: queryparams.Metadata{"key": "value"},
Key: examples.UserXPub,
Address: examples.Paymail,
})
if err != nil {
log.Fatalf("Failed to create paymail: %v", err)
}
exampleutil.PrettyPrint("Created paymail", paymail)
}