-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.go
43 lines (37 loc) · 985 Bytes
/
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
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
package main
import (
"fmt"
"github.com/diem/client-sdk-go/diemid"
"github.com/diem/client-sdk-go/diemkeys"
"github.com/diem/client-sdk-go/diemtypes"
"gopkg.in/yaml.v3"
)
func main() {
merchant := diemkeys.MustGenKeys()
address := merchant.AccountAddress()
currency := "XUS"
amount := uint64(5000)
account := diemid.NewAccount(
diemid.TestnetPrefix, address, diemtypes.EmptySubAddress)
intent := diemid.Intent{
Account: *account,
Params: diemid.Params{
Currency: currency,
Amount: &amount,
},
}
encodedIntent, err := intent.Encode()
if err != nil {
panic(err)
}
fmt.Printf("==== encoded intent identifier ====\n%v\n", encodedIntent)
decodedIntent, err := diemid.DecodeToIntent(diemid.TestnetPrefix, encodedIntent)
if err != nil {
panic(err)
}
fmt.Println("\n\n==== decoded intent ====")
yaml, _ := yaml.Marshal(decodedIntent)
fmt.Println(string(yaml))
}