-
Notifications
You must be signed in to change notification settings - Fork 1
/
AdaptorBTC.go.del
274 lines (245 loc) · 7.81 KB
/
AdaptorBTC.go.del
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* @author PalletOne core developers <dev@pallet.one>
* @date 2018
*/
package adaptor
type adapterbtc interface {
NewPrivateKey() (wifPriKey string)
GetPublicKey(wifPriKey string) (pubKey string)
GetAddress(wifPriKey string) (address string)
GetAddressByPubkey(pubKeyHex string) (string, error)
CreateMultiSigAddress(params *CreateMultiSigParams) (*CreateMultiSigResult, error)
RawTransactionGen(params *RawTransactionGenParams) (*RawTransactionGenResult, error)
DecodeRawTransaction(params *DecodeRawTransactionParams) (*DecodeRawTransactionResult, error)
GetTransactionByHash(params *GetTransactionByHashParams) (*GetTransactionByHashResult, error)
GetTransactionHttp(getTransactionByHashParams *GetTransactionHttpParams) (*GetTransactionHttpResult, error)
SignTransaction(params *SignTransactionParams) (*SignTransactionResult, error)
SignTxSend(params *SignTxSendParams) (*SignTxSendResult, error)
MergeTransaction(params *MergeTransactionParams) (*MergeTransactionResult, error)
SignMessage(signMessageParams *SignMessageParams) (*SignMessageResult, error)
VerifyMessage(verifyMessageParams *VerifyMessageParams) (*VerifyMessageResult, error)
GetUTXO(params *GetUTXOParams) (*GetUTXOResult, error)
GetUTXOHttp(params *GetUTXOHttpParams) (*GetUTXOHttpResult, error)
GetBalance(params *GetBalanceParams) (*GetBalanceResult, error)
GetTransactions(params *GetTransactionsParams) (*TransactionsResult, error)
SendTransaction(params *SendTransactionParams) (*SendTransactionResult, error)
SendTransactionHttp(sendTransactionParams *SendTransactionHttpParams) (*SendTransactionHttpResult, error)
}
//
type CreateMultiSigParams struct {
PublicKeys []string `json:"publicKeys"`
N int `json:"n"`
M int `json:"m"`
}
type CreateMultiSigResult struct {
P2ShAddress string `json:"p2sh_address"`
RedeemScript string `json:"redeem_script"`
Addresses []string `json:"addresses"`
}
//
type RawTransactionGenParams struct {
Inputs []Input `json:"inputs"`
Outputs []Output `json:"outputs"`
Locktime int64 `json:"locktime"`
}
type RawTransactionGenResult struct {
Rawtx string `json:"rawtx"`
}
//
type DecodeRawTransactionParams struct {
Rawtx string `json:"rawtx"`
}
type Input struct {
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
Addr string `json:"addr"`
}
type Output struct {
Address string `json:"address"`
Amount float64 `json:"amount"` //btc
}
type DecodeRawTransactionResult struct {
Inputs []Input `json:"inputs"`
Outputs []Output `json:"outputs"`
Locktime uint32 `json:"locktime"`
}
//
type GetTransactionByHashParams struct {
TxHash string `json:"txhash"`
}
type GetTransactionByHashResult struct {
Txid string `json:"txid"`
Confirms uint64 `json:"confirms"`
Inputs []Input `json:"inputs"`
Outputs []OutputIndex `json:"outputs"`
}
//
type GetTransactionHttpParams struct {
TxHash string `json:"txhash"`
}
type GetTransactionHttpResult struct {
Txid string `json:"txid"`
Confirms uint64 `json:"confirms"`
Inputs []Input `json:"inputs"`
Outputs []OutputIndex `json:"outputs"`
}
//
type SignTransactionParams struct {
TransactionHex string `json:"transactionhex"`
InputRedeemIndex []int `json:"inputredeemindex"`
RedeemHex []string `json:"redeemhex"`
FromAddr string `json:"fromaddr"` //empty when spend from MultiAddr
Privkeys []string `json:"privkeys"` //wif private keys
}
type SignTransactionResult struct {
Complete bool `json:"complete"`
TransactionHex string `json:"transactionhex"`
}
//
type SendTransactionParams struct {
TransactionHex string `json:"transactionhex"`
}
type SendTransactionResult struct {
TransactionHah string `json:"transactionhash"`
}
//
type SendTransactionHttpParams struct {
TransactionHex string `json:"transactionhex"`
}
type SendTransactionHttpResult struct {
TransactionHah string `json:"transactionhash"`
}
//
type SignTxSendParams struct {
TransactionHex string `json:"transactionhex"`
InputRedeemIndex []int `json:"inputredeemindex"`
RedeemHex []string `json:"redeemhex"`
FromAddr string `json:"fromaddr"`
Privkeys []string `json:"privkeys"` //wif private keys
}
type SignTxSendResult struct {
TransactionHah string `json:"transactionhash"`
Complete bool `json:"complete"`
TransactionHex string `json:"transactionhex"`
}
//
type MergeTransactionParams struct {
UserTransactionHex string `json:"usertransactionhex"`
MergeTransactionHexs []string `json:"mergetransactionhexs"`
InputRedeemIndex []int `json:"inputredeemindex"`
RedeemHex []string `json:"redeemhex"`
}
type MergeTransactionResult struct {
Complete bool `json:"complete"`
TransactionHash string `json:"transactionhash"`
TransactionHex string `json:"transactionhex"`
}
//
type SignMessageParams struct {
Message string `json:"message"`
Privkey string `json:"privkey"` //wif private key
}
type SignMessageResult struct {
Signature string `json:"signature"`
}
//
type VerifyMessageParams struct {
Message string `json:"message"`
Signature string `json:"signature"`
Address string `json:"address"`
}
type VerifyMessageResult struct {
Valid bool `json:"valid"`
}
//
type UTXO struct {
TxID string `json:"txid"`
Vout uint32 `json:"vout"`
Amount float64 `json:"amount"`
Confirms uint64 `json:"confirms"`
}
//
type GetUTXOParams struct {
Address string `json:"address"`
Minconf int `json:"minconf"`
Maxconf int `json:"maxconf"`
MaximumCount int `json:"maximumCount"`
}
type GetUTXOResult struct {
UTXOs []UTXO `json:"utxos"`
}
//
type GetUTXOHttpParams struct {
Address string `json:"address"`
Txid string `json:"txid"`
}
type GetUTXOHttpResult struct {
UTXOs []UTXO `json:"utxos"`
}
//
type GetBalanceParams struct {
Address string `json:"address"`
Minconf int `json:"minconf"`
}
type GetBalanceResult struct {
Value float64 `json:"value"` //btc
}
//
type GetBalanceHttpParams struct {
Address string `json:"address"`
Minconf int `json:"minconf"`
}
type GetBalanceHttpResult struct {
Value float64 `json:"value"` //btc
}
//
type GetTransactionsParams struct {
Account string `json:"account"`
Count int `json:"count"`
Skip int `json:"skip"`
}
type InputIndex struct {
TxHash string `json:"txHash"`
Index uint32 `json:"index"`
Addr string `json:"addr"`
Value float64 `json:"value"` //btc
}
type OutputIndex struct {
Index uint32 `json:"index"`
Addr string `json:"addr"`
Value float64 `json:"value"` //btc
}
type Transaction struct {
TxHash string `json:"txHash"`
BlanceChanged float64 `json:"blanceChanged"` //btc
Confirms uint64 `json:"confirms"`
Inputs []InputIndex `json:"inputs"`
Outputs []OutputIndex `json:"outputs"`
}
type TransactionsResult struct {
Transactions []Transaction `json:"transactions"`
}
/* not used current
type GetUTXOParams struct {
Addresses []string `json:"addresses"`
Minconf int `json:"minconf"`
Maxconf int `json:"maxconf"`
MaximumCount int `json:"maximumCount"`
}
func (abtc AdaptorBTC) GetUTXO(params string) string {
return GetUTXO(params, &abtc.RPCParams, abtc.NetID)
}
*/