forked from bcndev/bytecoin-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpcapi.go
593 lines (510 loc) · 22.2 KB
/
rpcapi.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
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
// Copyright 2019 The Bytecoin developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package bytecoin
const (
// walletd
GetStatusMethod = "get_status"
GetAddressesMethod = "get_addresses"
GetViewKeyPairMethod = "get_view_key_pair"
CreateAddressesMethod = "create_addresses"
GetBalanceMethod = "get_balance"
GetUnspentsMethod = "get_unspents"
GetTransfersMethod = "get_transfers"
CreateTransactionMethod = "create_transaction"
SendTransactionMethod = "send_transaction"
CreateSendproofMethod = "create_sendproof"
GetTransactionMethod = "get_transaction"
// bytecoind
GetRawBlockMethod = "get_raw_block"
GetBlockHeaderMethod = "get_block_header"
SyncBlocksMethod = "sync_blocks"
GetRawTransactionMethod = "get_raw_transaction"
SyncMemPoolMethod = "sync_mem_pool"
GetRandomOutputsMethod = "get_random_outputs"
CheckSendproofMethod = "check_sendproof"
GetStatisticsMethod = "get_statistics"
GetBlockTemplateMethodLegacy = "getblocktemplate"
GetBlockTemplateMethod = "get_block_template"
GetCurrencyIDMethodLegacy = "getcurrencyid"
GetCurrencyIDMethod = "get_currency_id"
SubmitBlockMethodLegacy = "submitblock"
SubmitBlockMethod = "submit_block"
GetLastBlockHeaderLegacyMethod = "getlastblockheader"
GetBlockHeaderByHashLegacyMethod = "getblockheaderbyhash"
GetBlockHeaderByHeightLegacyMethod = "getblockheaderbyheight"
)
const (
GetBalance_ADDRESS_FAILED_TO_PARSE = -4
GetBalance_INVALID_HEIGHT_OR_DEPTH = -2
GetBalance_ADDRESS_NOT_IN_WALLET = -1002
GetUnspents_ADDRESS_FAILED_TO_PARSE = -4
GetUnspents_INVALID_HEIGHT_OR_DEPTH = -2
GetUnspents_ADDRESS_NOT_IN_WALLET = -1002
GetTransfers_ADDRESS_FAILED_TO_PARSE = -4
GetTransfers_ADDRESS_NOT_IN_WALLET = -1002
CreateTransaction_NOT_ENOUGH_FUNDS = -301
CreateTransaction_TRANSACTION_DOES_NOT_FIT_IN_BLOCK = -302
CreateTransaction_NOT_ENOUGH_ANONYMITY = -303
CreateTransaction_VIEW_ONLY_WALLET = -304
CreateTransaction_INVALID_HEIGHT_OR_DEPTH = -2
CreateTransaction_ADDRESS_FAILED_TO_PARSE = -4
CreateTransaction_ADDRESS_NOT_IN_WALLET = -1002
SendTransaction_INVALID_TRANSACTION_BINARY_FORMAT = -101
SendTransaction_WRONG_OUTPUT_REFERENCE = -102
SendTransaction_OUTPUT_ALREADY_SPENT = -103
CreateSendproofResp_ADDRESS_FAILED_TO_PARSE = -4
GetRawBlock_HASH_NOT_FOUND = -4
GetRawBlock_INVALID_HEIGHT_OR_DEPTH = -2
GetBlockHeader_HASH_NOT_FOUND = -4
GetBlockHeader_INVALID_HEIGHT_OR_DEPTH = -2
GetRawTransaction_HASH_NOT_FOUND = -4
GetRandomOutputs_INVALID_HEIGHT_OR_DEPTH = -2
CheckSendproof_FAILED_TO_PARSE = -201
CheckSendproof_NOT_IN_MAIN_CHAIN = -202
CheckSendproof_WRONG_SIGNATURE = -203
CheckSendproof_ADDRESS_NOT_IN_TRANSACTION = -204
CheckSendproof_WRONG_AMOUNT = -205
GetBlockTemplate_ADDRESS_FAILED_TO_PARSE = -4
GetBlockTemplate_TOO_BIG_RESERVE_SIZE = -3
SubmitBlock_WRONG_BLOCKBLOB = -6
SubmitBlock_BLOCK_NOT_ACCEPTED = -7
SubmitBlockLegacy_WRONG_BLOCKBLOB = -6
SubmitBlockLegacy_BLOCK_NOT_ACCEPTED = -7
GetBlockHeaderByHashLegacy_HASH_NOT_FOUND = -5
GetBlockHeaderByHeight_INVALID_HEIGHT_OR_DEPTH = -2
)
type (
BinTransactionInput struct { // Mix of bytecoin::InputCoinbase and bytecoin::InputKey
Type string `json:"type"` // "coinbase" - coinbase, "key" - key input
Height int `json:"height"`
Amount uint64 `json:"amount,omitempty"`
OutputIndexes []int `json:"output_indexes,omitempty"`
KeyImage KeyImage `json:"key_image"`
}
BinTransactionOutput struct {
Amount uint64 `json:"amount"`
PublicKey PublicKey `json:"public_key"`
AmountCommitment *PublicKey `json:"amount_commitment,omitempty"`
EncryptedSecret *PublicKey `json:"encrypted_secret,omitempty"`
EncryptedAddressType HexBlob `json:"encrypted_address_type"` // actually single byte
Type string `json:"type"` // "key" - key output
}
BinTransactionPrefix struct {
Version int `json:"version"`
UnlockTime uint64 `json:"unlock_block_or_timestamp"`
Inputs []BinTransactionInput `json:"inputs,omitempty"`
Outputs []BinTransactionOutput `json:"outputs,omitempty"`
Extra HexBlob `json:"extra"`
}
BinTransaction struct {
BinTransactionPrefix
Signatures [][]string `json:"signatures"`
}
BinRootBlock struct {
MajorVersion int `json:"major_version"`
MinorVersion int `json:"minor_version"`
Nonce HexBlob `json:"nonce"`
Timestamp uint32 `json:"timestamp"`
PreviousBlockHash Hash `json:"previous_block_hash"`
TransactionCount int `json:"transaction_count"`
CoinbaseTransactionBranch []Hash `json:"coinbase_transaction_branch,omitempty"`
CoinbaseTransaction BinTransactionPrefix `json:"coinbase_transaction"`
BlockChainBranch []Hash `json:"blockchain_branch,omitempty"`
}
CMBranchElement struct {
Depth int `json:"depth"`
Hash Hash `json:"hash"`
}
BinBlockTemplate struct {
MajorVersion int `json:"major_version"`
MinorVersion int `json:"minor_version"`
Nonce HexBlob `json:"nonce"`
Timestamp uint32 `json:"timestamp"`
PreviousBlockHash Hash `json:"previous_block_hash"`
RootBlock BinRootBlock `json:"root_block"`
CMMerkleBranch []CMBranchElement `json:"cm_merkle_branch,omitempty"`
CoinbaseTransaction BinTransaction `json:"coinbase_transaction"`
TransactionHashes []Hash `json:"transaction_hashes,omitempty"`
}
CheckPoint struct {
Height int `json:"height"`
Hash Hash `json:"hash"`
KeyID int `json:"key_id"`
Counter uint64 `json:"counter"`
}
SignedCheckPoint struct {
CheckPoint
Signature string `json:"signature"`
}
Output struct {
TxVersion int `json:"transaction_version"`
Amount uint64 `json:"amount"`
PK PublicKey `json:"public_key"`
AmountCommitment PublicKey `json:"amount_commitment,omitempty"`
GlobalIndex int `json:"global_index"`
StackIndex int `json:"stack_index,omitempty"`
// Added from transaction
UnlockTime uint64 `json:"unlock_block_or_timestamp"`
IndexInTx int `json:"index_in_transaction"`
// Added from block
Height int `json:"height"`
// Added by wallet for recognized outputs
KeyImage KeyImage `json:"key_image"`
TransactionHash Hash `json:"transaction_hash"`
Address string `json:"address"`
}
Transfer struct {
Address string `json:"address"`
Amount int64 `json:"amount"`
Ours bool `json:"ours,omitempty"`
Locked bool `json:"locked,omitempty"`
UnlockTime uint64 `json:"unlock_block_or_timestamp,omitempty"`
Outputs []Output `json:"outputs,omitempty"`
TransactionHash Hash `json:"transaction_hash"`
}
Transaction struct {
// fields for new transactions
UnlockTime uint64 `json:"unlock_block_or_timestamp,omitempty"`
Transfers []Transfer `json:"transfers,omitempty"`
PaymentID Hash `json:"payment_id,omitempty"`
Anonymity int `json:"anonymity"`
// after transaction is created
Hash Hash `json:"hash"`
Fee uint64 `json:"fee"`
PK string `json:"public_key"`
Extra HexBlob `json:"extra"`
IsBase bool `json:"coinbase"`
Amount uint64 `json:"amount"`
// after transaction is included in block
BlockHeight int `json:"block_height"`
BlockHash Hash `json:"block_hash"`
Timestamp uint32 `json:"timestamp"`
Size int `json:"size,omitempty"`
}
BlockHeader struct {
MajorVersion int `json:"major_version"`
MinorVersion int `json:"minor_version"`
Timestamp uint32 `json:"timestamp"`
PreviousBlockHash Hash `json:"previous_block_hash"`
Nonce uint32 `json:"nonce"`
BinaryNonce HexBlob `json:"binary_nonce"`
Height int `json:"height"`
Hash Hash `json:"hash"`
Reward uint64 `json:"reward"`
CumulativeDifficulty uint64 `json:"cumulative_difficulty"`
CumulativeDifficultyHi uint64 `json:"cumulative_difficulty_hi"`
Difficulty uint64 `json:"difficulty"`
BaseReward uint64 `json:"base_reward"`
BlockSize int `json:"block_size"`
TransactionsSize int `json:"transactions_size"`
AlreadyGeneratedKeyOutputs int `json:"already_generated_key_outputs"`
AlreadyGeneratedCoins uint64 `json:"already_generated_coins"`
AlreadyGeneratedTransactions int `json:"already_generated_transactions"`
SizeMedian int `json:"size_median"`
EffectiveSizeMedian int `json:"effective_size_median"`
TimestampMedian uint32 `json:"timestamp_median"`
BlockCapacityVote int `json:"block_capacity_vote"`
BlockCapacityVoteMedian int `json:"block_capacity_vote_median"`
TransactionsFee uint64 `json:"transactions_fee"`
}
Block struct {
Header BlockHeader `json:"header"`
Transactions []Transaction `json:"transactions,omitempty"`
}
Balance struct {
Spendable uint64 `json:"spendable"`
SpendableDust uint64 `json:"spendable_dust"`
LockedOrUnconfirmed uint64 `json:"locked_or_unconfirmed"`
SpendableOutputs int `json:"spendable_outputs"`
SpendableDustOutputs int `json:"spendable_dust_outputs"`
LockedOrUnconfirmedOutputs int `json:"locked_or_unconfirmed_outputs"`
}
GetStatusReq struct {
TopBlockHash *Hash `json:"top_block_hash,omitempty"`
TxPoolVersion *int `json:"transaction_pool_version,omitempty"`
OutgoingPeerCount *int `json:"outgoing_peer_count,omitempty"`
IncomingPeerCount *int `json:"incoming_peer_count,omitempty"`
LowerLevelError *string `json:"lower_level_error,omitempty"`
}
GetStatusResp struct {
TopBlockHash Hash `json:"top_block_hash,omitempty"`
TxPoolVersion int `json:"transaction_pool_version,omitempty"`
OutgoingPeerCount int `json:"outgoing_peer_count,omitempty"`
IncomingPeerCount int `json:"incoming_peer_count,omitempty"`
LowerLevelError string `json:"lower_level_error,omitempty"`
TopBlockHeight int `json:"top_block_height"`
TopKnownBlockHeight int `json:"top_known_block_height"`
TopBlockDifficulty uint64 `json:"top_block_difficulty"`
TopBlockCumulativeDifficulty uint64 `json:"top_block_cumulative_difficulty"`
TopBlockCumulativeDifficultyHi uint64 `json:"top_block_cumulative_difficulty_hi"`
RecommendedFeePerKb uint64 `json:"recommended_fee_per_byte"`
TopBlockTimestamp uint32 `json:"top_block_timestamp"`
TopBlockTimestampMedian uint32 `json:"top_block_timestamp_median"`
RecommendedMaxTransactionSize int `json:"recommended_max_transaction_size"`
}
GetAddressesReq struct {
NeedSecretSpendKeys bool `json:"need_secret_spend_keys"`
FromAddress int `json:"from_address"`
MaxCount int `json:"max_count"`
}
GetAddressesResp struct {
ViewOnly bool `json:"view_only"`
WalletCreationTimestamp uint32 `json:"wallet_creation_timestamp"`
TotalAddressCount int `json:"total_address_count"`
Addresses []string `json:"addresses,omitempty"`
SecretSpendKeys []string `json:"secret_spend_keys,omitempty"`
}
GetViewKeyPairReq struct{}
GetViewKeyPairResp struct {
SecretViewKey string `json:"secret_view_key"`
PublicViewKey PublicKey `json:"public_view_key"`
ImportKeys string `json:"import_keys"`
}
CreateAddressesReq struct {
SecretSpendKeys []string `json:"secret_spend_keys,omitempty"`
CreationTimestamp uint32 `json:"creation_timestamp"`
}
CreateAddressesResp struct {
Addresses []string `json:"addresses,omitempty"`
SecretSpendKeys []string `json:"secret_spend_keys,omitempty"`
}
GetBalanceReq struct {
Address string `json:"address,omitempty"`
HeightOrDepth int `json:"height_or_depth"`
}
GetBalanceResp struct {
Balance
}
GetUnspentsReq struct {
Address string `json:"address,omitempty"`
HeightOrDepth int `json:"height_or_depth"`
}
GetUnspentsResp struct {
Spendable []Output `json:"spendable,omitempty"`
LockedOrUnconfirmed []Output `json:"locked_or_unconfirmed,omitempty"`
}
GetTransfersReq struct {
Address string `json:"address,omitempty"`
FromHeight int `json:"from_height"`
ToHeight int `json:"to_height"`
Forward bool `json:"forward"`
DesiredTransactionCount int `json:"desired_transaction_count"`
}
GetTransfersResp struct {
Blocks []Block `json:"blocks,omitempty"`
UnlockedTransfers []Transfer `json:"unlocked_transfers,omitempty"`
NextFromHeight int `json:"next_from_height"`
NextToHeight int `json:"next_to_height"`
}
CreateTransactionReq struct {
Transaction Transaction `json:"transaction"`
SpendAddresses []string `json:"spend_addresses,omitempty"`
AnySpendAddress bool `json:"any_spend_address"`
ChangeAddress string `json:"change_address,omitempty"`
ConfirmedHeightOrDepth int `json:"confirmed_height_or_depth"`
FeePerByte uint64 `json:"fee_per_byte"`
Optimization string `json:"optimization,omitempty"`
SaveHistory bool `json:"save_history"`
SubtractFeeFromAmount bool `json:"subtract_fee_from_amount"`
PreventConflictWithTransactions []string `json:"prevent_conflict_with_transactions,omitempty"`
}
CreateTransactionResp struct {
BinaryTransaction HexBlob `json:"binary_transaction,omitempty"`
Transaction Transaction `json:"transaction"`
SaveHistoryError bool `json:"save_history_error"`
TransactionsRequired []string `json:"transactions_required,omitempty"`
}
SendTransactionReq struct {
BinaryTransaction HexBlob `json:"binary_transaction,omitempty"`
}
SendTransactionResp struct {
SendResult string `json:"send_result,omitempty"`
}
CreateSendproofReq struct {
TransactionHash Hash `json:"transaction_hash,omitempty"`
Message string `json:"message,omitempty"`
Addresses []string `json:"addresses,omitempty"`
}
CreateSendproofResp struct {
Sendproofs []string `json:"sendproofs,omitempty"`
}
GetTransactionReq struct {
Hash Hash `json:"hash,omitempty"`
}
GetTransactionResp struct {
Transaction Transaction `json:"transaction"`
}
APIRawBlock struct {
Header BlockHeader `json:"header"`
RawHeader BinBlockTemplate `json:"raw_header"`
RawTransactions []BinTransactionPrefix `json:"raw_transactions,omitempty"`
Signatures [][][]string `json:"signatures,omitempty"`
Transactions []Transaction `json:"transactions,omitempty"`
OutputStackIndexes [][]int `json:"output_stack_indexes,omitempty"`
}
GetRawBlockReq struct {
Hash Hash `json:"hash"`
HeightOrDepth int `json:"height_or_depth"`
}
GetRawBlockResp struct {
Block APIRawBlock `json:"block"`
OrphanStatus bool `json:"orphan_status"`
Depth int `json:"depth"`
}
GetBlockHeaderReq struct {
Hash Hash `json:"hash"`
HeightOrDepth int `json:"height_or_depth"`
}
GetBlockHeaderResp struct {
BlockHeader `json:"block_header"`
OrphanStatus bool `json:"orphan_status"`
Depth int `json:"depth"`
}
SyncBlocksReq struct {
SparseChain []Hash `json:"sparse_chain,omitempty"`
FirstBlockTimestamp uint32 `json:"first_block_timestamp"`
MaxCount int `json:"max_count"`
MaxSize int `json:"max_size,omitempty"`
NeedRedundantData bool `json:"need_redundant_data"`
}
SyncBlocksResp struct {
Blocks []APIRawBlock `json:"blocks,omitempty"`
StartHeight int `json:"start_height"`
Status GetStatusResp `json:"status"`
}
GetRawTransactionReq struct {
Hash Hash `json:"hash"`
}
GetRawTransactionResp struct {
Transaction Transaction `json:"transaction"`
RawTransaction BinTransactionPrefix `json:"raw_transaction"`
Signatures [][]string `json:"signatures,omitempty"`
}
SyncMemPoolReq struct {
KnownHashes []Hash `json:"known_hashes,omitempty"` // should be sorted
NeedRedundantData bool `json:"need_redundant_data"`
}
SyncMemPoolResp struct {
RemovedHashes []Hash `json:"removed_hashes,omitempty"`
AddedRawTransactions []BinTransactionPrefix `json:"added_raw_transactions,omitempty"`
AddedSignatures [][][]string `json:"added_signatures,omitempty"`
AddedTransactions []Transaction `json:"added_transactions,omitempty"`
Status GetStatusResp `json:"status"`
}
GetRandomOutputsReq struct {
Amounts []uint64 `json:"amounts,omitempty"`
OutputCount int `json:"output_count"` // anonymity + 1
ConfirmedHeightOrDepth int `json:"confirmed_height_or_depth"`
}
GetRandomOutputsResp struct {
Outputs map[uint64][]Output `json:"outputs,omitempty"` // Not sure if json rpc can handle this in Go
}
Sendproof struct {
TransactionHash Hash `json:"transaction_hash"`
Address string `json:"address"`
Amount uint64 `json:"amount"`
Message string `json:"message"`
Proof string `json:"proof"`
}
CheckSendproofReq struct {
Sendproof string `json:"sendproof"`
}
CheckSendproofResp struct {
TransactionHash Hash `json:"transaction_hash"`
Address string `json:"address"`
Amount uint64 `json:"amount"`
Message string `json:"message"`
OutputIndexes []int `json:"output_indexes,omitempty"`
}
GetStatisticsReq struct{}
GetStatisticsResp struct {
Version string `json:"version"`
Platform string `json:"platform"`
StartTime uint32 `json:"start_time"`
Net string `json:"net"`
GenesisBlockHash Hash `json:"genesis_block_hash"`
PeerID uint64 `json:"peer_id"`
// TODO peer_list_white
// TODO peer_list_gray
// TODO connected_peers
Checkpoints []SignedCheckPoint `json:"checkpoints,omitempty"`
UpgradeDecidedHeight int `json:"upgrade_decided_height"`
NodeDatabaseSize uint64 `json:"node_database_size"`
}
GetBlockTemplateReq struct {
ReserveSize int `json:"reserve_size,omitempty"`
WalletAddress string `json:"wallet_address"`
TopBlockHash *Hash `json:"top_block_hash,omitempty"` // for longpoll
TransactionPoolVersion *int `json:"transaction_pool_version,omitempty"` // for longpoll
}
GetBlockTemplateResp struct {
Difficulty uint64 `json:"difficulty"`
Height int `json:"height"`
ReserveOffset int `json:"reserved_offset"`
BlockTemplateBlob HexBlob `json:"blocktemplate_blob"`
Status string `json:"status"`
TopBlockHash Hash `json:"top_block_hash"` // for longpoll
TransactionPoolVersion int `json:"transaction_pool_version"` // for longpoll
CMPreHash Hash `json:"cm_prehash"`
CMPath Hash `json:"cm_path"`
}
GetCurrencyIDReq struct{}
GetCurrencyIDResp struct {
CurrencyIDBlob Hash `json:"currency_id_blob"`
}
SubmitBlockReq struct {
BlockTemplateBlob HexBlob `json:"blocktemplate_blob"`
CMNonce HexBlob `json:"cm_nonce"`
CMMerkleBranch []CMBranchElement `json:"cm_merkle_branch,omitempty"`
}
SubmitBlockResp struct {
BlockHeader BlockHeader `json:"block_header"`
OrphanStatus bool `json:"orphan_status"`
Depth int `json:"depth"`
}
SubmitBlockLegacyReq []HexBlob
SubmitBlockLegacyResp struct {
Status string `json:"status"`
}
BlockHeaderLegacy struct {
BlockHeader
OrphanStatus bool `json:"orphan_status"`
Depth int `json:"depth"`
}
GetLastBlockHeaderLegacyReq struct{}
GetLastBlockHeaderLegacyResp struct {
BlockHeader BlockHeaderLegacy `json:"block_header"`
Status string `json:"status"`
}
GetBlockHeaderByHashLegacyReq struct {
Hash Hash `json:"hash"`
}
GetBlockHeaderByHashLegacyResp struct {
BlockHeader BlockHeaderLegacy `json:"block_header"`
Status string `json:"status"`
}
GetBlockHeaderByHeightLegacyReq struct {
Height int `json:"height"`
}
GetBlockHeaderByHeightLegacyResp struct {
BlockHeader BlockHeaderLegacy `json:"block_header"`
Status string `json:"status"`
}
)
func (p BlockHeader) Capacity() int {
if p.BlockCapacityVoteMedian == 0 {
return p.EffectiveSizeMedian * 2
}
return p.BlockCapacityVoteMedian
}