-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAdaptorETH.go.del
231 lines (206 loc) · 6.88 KB
/
AdaptorETH.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
/*
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 <[email protected]>
* @date 2018
*/
package adaptor
type adaptereth interface {
NewPrivateKey() (prikeyHex string)
GetPublicKey(prikeyHex string) (pubKey string)
GetAddress(prikeyHex string) (address string)
Keccak256HashPackedSig(params *Keccak256HashPackedSigParams) (*Keccak256HashPackedSigResult, error)
RecoverAddr(params *RecoverParams) (*RecoverResult, error)
SignTransaction(params *ETHSignTransactionParams) (*ETHSignTransactionResult, error) //not same as btc, members
SendTransaction(params *SendTransactionParams) (*SendTransactionResult, error) //same as btc
QueryContract(params *QueryContractParams) (*QueryContractResult, error)
GenInvokeContractTX(params *GenInvokeContractTXParams) (*GenInvokeContractTXResult, error)
GenDeployContractTX(params *GenDeployContractTXParams) (*GenDeployContractTXResult, error)
GetEventByAddress(params *GetEventByAddressParams) (*GetEventByAddressResult, error)
GetTransactionByHash(params *GetTransactionParams) (*GetTransactionResult, error)
GetErc20TxByHash(params *GetErc20TxByHashParams) (*GetErc20TxByHashResult, error)
GetBestHeader(params *GetBestHeaderParams) (*GetBestHeaderResult, error)
}
//
type CreateMultiSigAddressParams struct {
Addresses []string `json:"addresses"`
N int `json:"n"`
M int `json:"m"`
}
type CreateMultiSigAddressResult struct {
RedeemHex string `json:"redeemhex"`
}
//
type Keccak256HashPackedSigParams struct {
PrivateKeyHex string `json:"privatekeyhex"`
ParamTypes string `json:"paramtypes"`
Params string `json:"params"`
}
type Keccak256HashPackedSigResult struct {
Hash string `json:"hash"`
Signature string `json:"signature"`
}
//
type Keccak256HashVerifyParams struct {
PublicKeyHex string `json:"publickeyhex"`
Hash string `json:"hash"`
Signature string `json:"signature"`
}
type Keccak256HashVerifyResult struct {
Valid bool `json:"valid"`
}
//
type RecoverParams struct {
Hash string `json:"hash"`
Signature string `json:"signature"`
}
type RecoverResult struct {
Addr string `json:"addr"`
}
//not same as btc, members
type ETHSignTransactionParams struct {
PrivateKeyHex string `json:"privatekeyhex"`
TransactionHex string `json:"transactionhex"`
}
type ETHSignTransactionResult struct {
TransactionHex string `json:"transactionhex"`
}
////same as btc
//type SendTransactionParams struct {
// TransactionHex string `json:"transactionhex"`
//}
//type SendTransactionResult struct {
// TransactionHah string `json:"transactionhash"`
//}
//
type QueryContractParams struct {
ContractABI string `json:"contractABI"`
ContractAddr string `json:"contractAddr"`
Method string `json:"method"`
Params string `json:"params"`
ParamsArray []interface{} `json:"paramsarray"`
}
type QueryContractResult struct {
Result string `json:"result"`
}
//
type GenInvokeContractTXParams struct {
ContractABI string `json:"contractabi"`
ContractAddr string `json:"contractaddr"`
CallerAddr string `json:"calleraddr"`
Value string `json:"value"`
GasPrice string `json:"gasprice"`
GasLimit string `json:"gaslimit"`
Method string `json:"method"`
Params string `json:"params"`
ParamsArray []interface{} `json:"paramsarray"`
}
type GenInvokeContractTXResult struct {
TransactionHex string `json:"transactionhex"`
}
//
type GenDeployContractTXParams struct {
ContractABI string `json:"contractabi"`
ContractBin string `json:"contractbin"`
DeployerAddr string `json:"deployeraddr"`
Value string `json:"value"`
GasPrice string `json:"gasprice"`
GasLimit string `json:"gaslimit"`
Params string `json:"params"`
ParamsArray []interface{} `json:"paramsarray"`
}
type GenDeployContractTXResult struct {
TransactionHex string `json:"transactionhex"`
ContractAddr string `json:"contractaddr"`
}
//
type GetEventByAddressParams struct {
ContractABI string `json:"contractABI"`
ContractAddr string `json:"contractAddr"`
ConcernAddr string `json:"concernaddr"`
StartHeight string `json:"startheight"`
EndHeight string `json:"endheight"`
EventName string `json:"eventname"`
}
type GetEventByAddressResult struct {
Events []string `json:"events"`
Txhashs []string `json:"txhashs"`
Blocknums []uint64 `json:"blocknums"`
}
//
type GetTransactionParams struct {
Hash string `json:"hash"`
}
type GetTransactionResult struct {
Hash string `json:"hash"`
Nonce string `json:"nonce"`
BlockHash string `json:"blockHash"`
BlockNumber string `json:"blockNumber"`
From string `json:"from"`
To string `json:"to"`
Value string `json:"value"`
Gas string `json:"gas"`
GasPrice string `json:"gasPrice"`
Input string `json:"input"`
}
//
type GetErc20TxByHashParams struct {
Hash string `json:"hash"`
}
type GetErc20TxByHashResult struct {
Hash string `json:"hash"`
Status string `json:"status"`
BlockHash string `json:"blockHash"`
BlockNumber string `json:"blockNumber"`
ContractAddr string `json:"contractaddr"`
From string `json:"from"`
To string `json:"to"`
Amount string `json:"amount"`
}
//
type GetBestHeaderParams struct {
Number string `json:"Number"` //if empty, return the best header
}
type GetBestHeaderResult struct {
TxHash string `json:"txhash"`
Number string `json:"number"`
}
/* not used current
//
type GetBalanceParams struct {
Account string `json:"account"`
}
type GetBalanceResult struct {
Balance float64 `json:"balance"`
}
func (aeth AdaptorETH) GetBalance(params string) string {
return GetBalance(params, &aeth.RPCParams, aeth.NetID)
}
//
type CalculateSigParams struct {
PrivateKeyHex string `json:"privatekeyhex"`
PalletContractAddr string `json:"palletcontractaddr"`
TokenAddr string `json:"tokenaddr"`
RedeemHex string `json:"redeemhex"`
RecverAddr string `json:"recveraddr"`
Amount string `json:"amount"`
Nonece string `json:"nonece"`
}
type CalculateSigResult struct {
Signature string `json:"signature"`
}
func (aeth AdaptorETH) CalculateSig(params string) string {
return CalculateSig(params)
}
*/