-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjsonresults.go
More file actions
149 lines (132 loc) · 3.78 KB
/
jsonresults.go
File metadata and controls
149 lines (132 loc) · 3.78 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package nmcjson
import (
"encoding/json"
)
// NameNewResult models the data from the name_new command.
type NameNewResult struct {
Txid string
Rand string
}
// NameUpdateResult models the data from the name_new command.
type NameUpdateResult string
// NameFirstUpdateResult models the data from the name_firstupdate command.
type NameFirstUpdateResult string
// NameShowResult models the data from the name_show command.
type NameShowResult struct {
Name string `json:"name"`
Value string `json:"value"`
Txid string `json:"txid"`
Vout int `json:"vout",omitempty`
Address string `json:"address"`
Height int64 `json:"height",omitempty`
ExpiresIn int64 `json:"expires_in"`
Expired bool `json:"expired",omitempty`
}
// NameListResult models the data from the name_list command.
type NameListResult struct {
Name string `json:"name"`
Value string `json:"value"`
Txid string `json:"txid",omitempty`
Vout int `json:"vout",omitempty`
Address string `json:"address"`
Height int64 `json:"height",omitempty`
ExpiresIn int64 `json:"expires_in"`
Expired bool `json:"expired",omitempty`
Transferred bool `json:"transferred",omitempty"`
}
// NameHistoryResult models the data from the name_history command.
type NameHistoryResult NameShowResult
// NameScanResult models the data from the name_scan command.
type NameScanResult struct {
Name string `json:"name"`
Value string `json:"value"`
Txid string `json:"txid",omitempty`
Vout int `json:"vout",omitempty`
Address string `json:"address",omitempty`
Height int64 `json:"height",omitempty`
ExpiresIn int64 `json:"expires_in"`
Expired bool `json:"expired",omitempty`
}
// NameFilterResult models the data from the name_filter command.
type NameFilterResult NameScanResult
// NameNewReplyParse is a ReplyParser.
func NameNewReplyParse(msg json.RawMessage) (interface{}, error) {
var res NameNewResult
strs := make([]string, 0, 2)
err := json.Unmarshal(msg, &strs)
if err != nil {
return nil, err
}
//err := json.Unmarshal(msg, &res)
//if err != nil {
// return nil, err
//}
res = NameNewResult{
Txid: strs[0],
Rand: strs[1],
}
return res, nil
}
// NameUpdateReplyParse is a ReplyParser.
func NameUpdateReplyParse(msg json.RawMessage) (interface{}, error) {
var res NameUpdateResult
err := json.Unmarshal(msg, &res)
if err != nil {
return nil, err
}
return res, nil
}
// NameFirstUpdateReplyParse is a ReplyParser.
func NameFirstUpdateReplyParse(msg json.RawMessage) (interface{}, error) {
var res NameFirstUpdateResult
err := json.Unmarshal(msg, &res)
if err != nil {
return nil, err
}
return res, nil
}
// NameShowReplyParse is a ReplyParser.
func NameShowReplyParse(msg json.RawMessage) (interface{}, error) {
var res NameShowResult
err := json.Unmarshal(msg, &res)
if err != nil {
return nil, err
}
return res, nil
}
// NameListReplyParse is a ReplyParser.
func NameListReplyParse(msg json.RawMessage) (interface{}, error) {
var res []NameListResult
err := json.Unmarshal(msg, &res)
if err != nil {
return nil, err
}
return res, nil
}
// NameHistoryReplyParse is a ReplyParser.
func NameHistoryReplyParse(msg json.RawMessage) (interface{}, error) {
var res []NameHistoryResult
err := json.Unmarshal(msg, &res)
if err != nil {
return nil, err
}
return res, nil
}
// NameScanReplyParse is a ReplyParser.
func NameScanReplyParse(msg json.RawMessage) (interface{}, error) {
var res []NameScanResult
err := json.Unmarshal(msg, &res)
if err != nil {
return nil, err
}
return res, nil
}
// NameFilterReplyParse is a ReplyParser.
func NameFilterReplyParse(msg json.RawMessage) (interface{}, error) {
var res []NameFilterResult
err := json.Unmarshal(msg, &res)
if err != nil {
return nil, err
}
return res, nil
}