forked from planetdecred/dcrlibwallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresponse.go
168 lines (149 loc) · 3.61 KB
/
response.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
package mobilewallet
type UnsignedTransaction struct {
UnsignedTransaction []byte
EstimatedSignedSize int
ChangeIndex int
TotalOutputAmount int64
TotalPreviousOutputAmount int64
}
type Balance struct {
Total int64
Spendable int64
ImmatureReward int64
ImmatureStakeGeneration int64
LockedByTickets int64
VotingAuthority int64
UnConfirmed int64
}
type Account struct {
Number int32
Name string
Balance *Balance
TotalBalance int64
ExternalKeyCount int32
InternalKeyCount int32
ImportedKeyCount int32
}
type Accounts struct {
Count int
ErrorMessage string
ErrorCode int
ErrorOccurred bool
Acc *[]Account
CurrentBlockHash []byte
CurrentBlockHeight int32
}
type BlockScanResponse interface {
OnScan(rescannedThrough int32) bool
OnEnd(height int32, cancelled bool)
OnError(err string)
}
/*
Direction
0: Sent
1: Received
2: Transfered
*/
type Transaction struct {
Hash string
Raw string
Transaction []byte
Fee int64
Timestamp int64
Type string
Amount int64
Status string
Height int32
Direction int32
Debits *[]TransactionDebit
Credits *[]TransactionCredit
}
type TransactionDebit struct {
Index int32
PreviousAccount int32
PreviousAmount int64
AccountName string
}
type TransactionCredit struct {
Index int32
Account int32
Internal bool
Amount int64
Address string
}
type getTransactionsResponse struct {
Transactions []Transaction
ErrorOccurred bool
ErrorMessage string
}
type GetTransactionsResponse interface {
OnResult(json string)
}
type TransactionListener interface {
OnTransaction(transaction string)
OnTransactionConfirmed(hash string, height int32)
OnBlockAttached(height int32, timestamp int64)
}
type DecodedTransaction struct {
Hash string
Type string
Version int32
LockTime int32
Expiry int32
Inputs []DecodedInput
Outputs []DecodedOutput
//Vote Info
VoteVersion int32
LastBlockValid bool
VoteBits string
}
type DecodedInput struct {
PreviousTransactionHash string
PreviousTransactionIndex int32
AmountIn int64
}
type DecodedOutput struct {
Index int32
Value int64
Version int32
ScriptType string
Addresses []string
}
type SpvSyncResponse interface {
OnPeerConnected(peerCount int32)
OnPeerDisconnected(peerCount int32)
OnFetchMissingCFilters(missingCFitlersStart, missingCFitlersEnd int32, state string)
OnFetchedHeaders(fetchedHeadersCount int32, lastHeaderTime int64, state string)
OnDiscoveredAddresses(state string)
OnRescan(rescannedThrough int32, state string)
OnSynced(synced bool)
/*
* Handled Error Codes
* -1 - Unexpected Error
* 1 - Context Canceled
* 2 - Deadline Exceeded
* 3 - Invalid Address
*/
OnSyncError(code int, err error)
}
const (
// Error Codes
ErrInsufficientBalance = "insufficient_balance"
ErrInvalid = "invalid"
ErrWalletNotLoaded = "wallet_not_loaded"
ErrPassphraseRequired = "passphrase_required"
ErrInvalidPassphrase = "invalid_passphrase"
ErrNotConnected = "not_connected"
ErrNotExist = "not_exists"
ErrEmptySeed = "empty_seed"
ErrInvalidAddress = "invalid_address"
ErrInvalidAuth = "invalid_auth"
ErrUnavailable = "unavailable"
ErrContextCanceled = "context_canceled"
ErrFailedPrecondition = "failed_precondition"
ErrNoPeers = "no_peers"
//Sync States
START = "start"
FINISH = "finish"
PROGRESS = "progress"
)