forked from joeqian10/neo3-gogogo
/
rpcClient.Wallet.go
172 lines (145 loc) · 4.39 KB
/
rpcClient.Wallet.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package rpc
import "github.com/mghnmtt/neo3-gogogo/rpc/models"
type CloseWalletResponse struct {
RpcResponse
ErrorResponse
Result bool `json:"result"`
}
type DumpPrivKeyResponse struct {
RpcResponse
ErrorResponse
Result string `json:"result"`
}
type GetNewAddressResponse struct {
RpcResponse
ErrorResponse
Result string `json:"result"`
}
type GetWalletBalanceResponse struct {
RpcResponse
ErrorResponse
Result models.RpcWalletBalance `json:"result"`
}
type GetWalletUnclaimedGasResponse struct {
RpcResponse
ErrorResponse
Result string `json:"result"`
}
type ImportPrivKeyResponse struct {
RpcResponse
ErrorResponse
Result models.RpcAddress `json:"result"`
}
type CalculateNetworkFeeResponse struct {
RpcResponse
ErrorResponse
Result models.RpcNetworkFee `json:"result"`
}
type ListAddressResponse struct {
RpcResponse
ErrorResponse
Result []models.RpcAddress `json:"result"`
}
type OpenWalletResponse struct {
RpcResponse
ErrorResponse
Result bool `json:"result"`
}
type SendFromResponse struct {
RpcResponse
ErrorResponse
Result models.RpcTransaction `json:"result"`
}
type SendManyResponse struct {
RpcResponse
ErrorResponse
Result models.RpcTransaction `json:"result"`
}
type SendToAddressResponse struct {
RpcResponse
ErrorResponse
Result models.RpcTransaction `json:"result"`
}
func (n *RpcClient) CloseWallet() CloseWalletResponse {
response := CloseWalletResponse{}
params := []interface{}{}
_ = n.makeRequest("closewallet", params, &response)
return response
}
func (n *RpcClient) DumpPrivKey(address string) DumpPrivKeyResponse {
response := DumpPrivKeyResponse{}
params := []interface{}{address}
_ = n.makeRequest("dumpprivkey", params, &response)
return response
}
func (n *RpcClient) GetNewAddress() GetNewAddressResponse {
response := GetNewAddressResponse{}
params := []interface{}{}
_ = n.makeRequest("getnewaddress", params, &response)
return response
}
func (n *RpcClient) GetWalletBalance(assetId string) GetWalletBalanceResponse {
response := GetWalletBalanceResponse{}
params := []interface{}{assetId}
_ = n.makeRequest("getwalletbalance", params, &response)
return response
}
func (n *RpcClient) GetWalletUnclaimedGas() GetWalletUnclaimedGasResponse {
response := GetWalletUnclaimedGasResponse{}
params := []interface{}{}
_ = n.makeRequest("getwalletunclaimedgas", params, &response)
return response
}
func (n *RpcClient) ImportPrivKey(wif string) ImportPrivKeyResponse {
response := ImportPrivKeyResponse{}
params := []interface{}{wif}
_ = n.makeRequest("importprivkey", params, &response)
return response
}
func (n *RpcClient) CalculateNetworkFee(tx string) CalculateNetworkFeeResponse {
response := CalculateNetworkFeeResponse{}
params := []interface{}{tx}
_ = n.makeRequest("calculatenetworkfee", params, &response)
return response
}
func (n *RpcClient) ListAddress() ListAddressResponse {
response := ListAddressResponse{}
params := []interface{}{}
_ = n.makeRequest("listaddress", params, &response)
return response
}
func (n *RpcClient) OpenWallet(path string, password string) OpenWalletResponse {
response := OpenWalletResponse{}
params := []interface{}{path, password}
_ = n.makeRequest("openwallet", params, &response)
return response
}
func (n *RpcClient) SendFrom(assetId string, from string, to string, amount string) SendFromResponse {
response := SendFromResponse{}
params := []interface{}{assetId, from, to, amount}
_ = n.makeRequest("sendfrom", params, &response)
return response
}
func (n *RpcClient) SendMany(fromAddress string, outputs []models.RpcTransferOut, signers ...models.RpcSigner) SendManyResponse {
response := SendManyResponse{}
var params []interface{}
if fromAddress == "" {
params = []interface{}{outputs, signers}
} else {
params = []interface{}{fromAddress, outputs, signers}
}
_ = n.makeRequest("sendfrom", params, &response)
return response
}
func (n *RpcClient) SendToAddress(assetId string, to string, amount string) SendToAddressResponse {
response := SendToAddressResponse{}
params := []interface{}{assetId, to, amount}
_ = n.makeRequest("sendtoaddress", params, &response)
return response
}
func (n *RpcClient) InvokeContractVerify(scriptHash string, args []models.RpcContractParameter, signers []models.RpcSigner) InvokeResultResponse {
response := InvokeResultResponse{}
params := []interface{}{scriptHash, args, signers}
_ = n.makeRequest("invokecontractverify", params, &response)
return response
}