This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
models.go
848 lines (764 loc) · 26.4 KB
/
models.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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
package blockstack
import (
"encoding/base64"
"encoding/json"
"log"
)
// StartBlock is the first block on the bitcoin blockchain with blockstack transactions
const StartBlock = 373601
// GetInfoResult is the go represenation of the getinfo rpc method
type GetInfoResult struct {
ServerAlive bool `json:"server_alive"`
ZonefileCount int `json:"zonefile_count"`
LastBlockProcessed int `json:"last_block_processed"`
Indexing bool `json:"indexing"`
Consensus string `json:"consensus"`
LastBlockSeen int `json:"last_block_seen"`
ServerVersion string `json:"server_version"`
}
// JSON returns the JSON representation of GetInfoResult
func (r GetInfoResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetInfoResult
func (r GetInfoResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// Transaction models a Bitcoin Transaction for various structs here
type Transaction struct {
ValueHash string `json:"value_hash"`
LastRenewed int `json:"last_renewed"`
LastCreationOp string `json:"last_creation_op"`
Revoked bool `json:"revoked"`
SenderPubkey string `json:"sender_pubkey"`
BlockNumber int `json:"block_number"`
ConsensusHash string `json:"consensus_hash"`
NamespaceBlockNumber int `json:"namespace_block_number"`
PreorderBlockNumber int `json:"preorder_block_number"`
Vtxindex int `json:"vtxindex"`
Op string `json:"op"`
Txid string `json:"txid"`
Importer string `json:"importer"`
Opcode string `json:"opcode"`
OpFee float64 `json:"op_fee"`
Address string `json:"address"`
PreorderHash string `json:"preorder_hash"`
ImporterAddress string `json:"importer_address"`
FirstRegistered int `json:"first_registered"`
TransferSendBlockID int `json:"transfer_send_block_id"`
Sender string `json:"sender"`
}
// JSON returns the JSON representation of Transaction
func (r Transaction) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of Transaction
func (r Transaction) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNameBlockchainRecordResult needs testing rpc method get_name_blockchain_record
type GetNameBlockchainRecordResult struct {
Status bool `json:"status"`
Record struct {
RenewalDeadline int `json:"renewal_deadline"`
BlockNumber int `json:"block_number"`
LastCreationOp string `json:"last_creation_op"`
NamespaceID string `json:"namespace_id"`
NamespaceBlockNumber int `json:"namespace_block_number"`
ExpireBlock int `json:"expire_block"`
Address string `json:"address"`
ImporterAddress string `json:"importer_address"`
Expired bool `json:"expired"`
TransferSendBlockID interface{} `json:"transfer_send_block_id"`
Sender string `json:"sender"`
ValueHash string `json:"value_hash"`
LastRenewed int `json:"last_renewed"`
Name string `json:"name"`
Revoked bool `json:"revoked"`
ConsensusHash string `json:"consensus_hash"`
PreorderBlockNumber int `json:"preorder_block_number"`
Txid string `json:"txid"`
Importer string `json:"importer"`
NameHash128 string `json:"name_hash128"`
Opcode string `json:"opcode"`
OpFee int `json:"op_fee"`
SenderPubkey string `json:"sender_pubkey"`
PreorderHash string `json:"preorder_hash"`
History map[int][]Transaction `json:"history"`
}
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of GetNameBlockchainRecordResult
func (r GetNameBlockchainRecordResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNameBlockchainRecordResult
func (r GetNameBlockchainRecordResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// LastTx returns the last transcation from the history
func (r GetNameBlockchainRecordResult) LastTx() Transaction {
var tx int
for block := range r.Record.History {
if block > tx {
tx = block
}
}
return r.Record.History[tx][0]
}
// PingResult is the go represenation of the ping rpc method
type PingResult struct {
Status string `json:"status"`
}
// JSON returns the JSON representation of PingResult
func (r PingResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of PingResult
func (r PingResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNameHistoryBlocksResult is the go represenation of the get_name_history_blocks method
type GetNameHistoryBlocksResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
HistoryBlocks []int `json:"history_blocks"`
}
// JSON returns the JSON representation of GetNameHistoryBlocksResult
func (r GetNameHistoryBlocksResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNameHistoryBlocksResult
func (r GetNameHistoryBlocksResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNameAtResult is the go represenation of the get_name_at method
type GetNameAtResult struct {
Status bool `json:"status"`
Records []struct {
BlockNumber int `json:"block_number"`
NamespaceID string `json:"namespace_id"`
ImporterAddress string `json:"importer_address"`
ValueHash string `json:"value_hash"`
ConsensusHash string `json:"consensus_hash"`
Txid string `json:"txid"`
Importer string `json:"importer"`
NameHash128 string `json:"name_hash128"`
TransferSendBlockID interface{} `json:"transfer_send_block_id"`
PreorderHash string `json:"preorder_hash"`
FirstRegistered int `json:"first_registered"`
LastCreationOp string `json:"last_creation_op"`
Name string `json:"name"`
NamespaceBlockNumber int `json:"namespace_block_number"`
Address string `json:"address"`
OpFee int `json:"op_fee"`
Revoked bool `json:"revoked"`
LastRenewed int `json:"last_renewed"`
Sender string `json:"sender"`
SenderPubkey string `json:"sender_pubkey"`
PreorderBlockNumber int `json:"preorder_block_number"`
Opcode string `json:"opcode"`
Op string `json:"op"`
Vtxindex int `json:"vtxindex"`
} `json:"records"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of GetNameAtResult
func (r GetNameAtResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNameAtResult
func (r GetNameAtResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNamesOwnedByAddressResult is the go represenation of the get_names_owned_by_address method
type GetNamesOwnedByAddressResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Names []string `json:"names"`
}
// JSON returns the JSON representation of GetNamesOwnedByAddressResult
func (r GetNamesOwnedByAddressResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNamesOwnedByAddressResult
func (r GetNamesOwnedByAddressResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNameCostResult is the go represenation of the get_name_cost method
type GetNameCostResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Satoshis int `json:"satoshis"`
}
// JSON returns the JSON representation of GetNameCostResult
func (r GetNameCostResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNameCostResult
func (r GetNameCostResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNamespaceCostResult is the go represenation of the get_name_cost method
type GetNamespaceCostResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Satoshis int `json:"satoshis"`
}
// JSON returns the JSON representation of GetNamespaceCostResult
func (r GetNamespaceCostResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNamespaceCostResult
func (r GetNamespaceCostResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetAllNamesResult is the go represenation of the get_all_names method
type GetAllNamesResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Names []string `json:"names"`
}
// JSON returns the JSON representation of GetAllNamesResult
func (r GetAllNamesResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetAllNamesResult
func (r GetAllNamesResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetAllNamespacesResult is the go represenation of the get_all_namespaces method
type GetAllNamespacesResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Namespaces []string `json:"namespaces"`
}
// JSON returns the JSON representation of GetAllNamespacesResult
func (r GetAllNamespacesResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetAllNamespacesResult
func (r GetAllNamespacesResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNamesInNamespaceResult is the go represenation of the get_names_in_namespace rpc method
type GetNamesInNamespaceResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Names []string `json:"names"`
}
// JSON returns the JSON representation of GetNamesInNamespaceResult
func (r GetNamesInNamespaceResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNamesInNamespaceResult
func (r GetNamesInNamespaceResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetConsensusAtResult is the go represenation of the get_consensus_at method
type GetConsensusAtResult struct {
Status bool `json:"status"`
Consensus string `json:"consensus"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of GetConsensusAtResult
func (r GetConsensusAtResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetConsensusAtResult
func (r GetConsensusAtResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetBlockFromConsensusResult is the go represenation of the get_block_from_consensus method
type GetBlockFromConsensusResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
BlockID int `json:"block_id"`
}
// JSON returns the JSON representation of GetBlockFromConsensusResult
func (r GetBlockFromConsensusResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetBlockFromConsensusResult
func (r GetBlockFromConsensusResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// ZonefileHashResult is a go represenation of a zonefile_hash_result
type ZonefileHashResult struct {
Txid string `json:"txid"`
Name string `json:"name"`
ZonefileHash string `json:"zonefile_hash"`
BlockHeight int `json:"block_height"`
}
// ZonefileHashResults is a collection of ZonefileHashResult
type ZonefileHashResults []ZonefileHashResult
// Zonefiles returns zonefiles from a ZonefileHashResults
func (zfhr ZonefileHashResults) Zonefiles() []string {
var out []string
for _, zfh := range zfhr {
out = append(out, zfh.ZonefileHash)
}
return out
}
// LatestZonefileHash returns the latest zonefile from a batch for a given zonefileHash
func (zfhr ZonefileHashResults) LatestZonefileHash(zonefileHash string) ZonefileHashResult {
var out ZonefileHashResult
for _, zfh := range zfhr {
if zfh.ZonefileHash == zonefileHash && zfh.BlockHeight > out.BlockHeight {
out = zfh
}
}
return out
}
// GetZonefilesByBlockResult is the go represenation of the get_zonefiles_by_block rpc method
type GetZonefilesByBlockResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
ZonefileInfo []ZonefileHashResult `json:"zonefile_info"`
}
// JSON returns the JSON representation of GetZonefilesByBlockResult
func (r GetZonefilesByBlockResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetZonefilesByBlockResult
func (r GetZonefilesByBlockResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// Zonefiles is an affordance to return the zonefile hashes in []string
func (r GetZonefilesByBlockResult) Zonefiles() []string {
var out []string
for _, zfh := range r.ZonefileInfo {
out = append(out, zfh.ZonefileHash)
}
return out
}
// GetAtlasPeersResult is the go represenation of the get_atlas_peers rpc method
type GetAtlasPeersResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Peers []string `json:"peers"`
}
// JSON returns the JSON representation of GetAtlasPeersResult
func (r GetAtlasPeersResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetAtlasPeersResult
func (r GetAtlasPeersResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetZonefileInventoryResult is the go represenation of the get_zonefile_inventory rpc method
type GetZonefileInventoryResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Inv string `json:"inv"`
}
// JSON returns the JSON representation of GetZonefileInventoryResult
func (r GetZonefileInventoryResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetZonefileInventoryResult
func (r GetZonefileInventoryResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNameOpsHashAtResult is the go represenation of the get_nameops_hash_at rpc method
type GetNameOpsHashAtResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
OpsHash string `json:"ops_hash"`
}
// JSON returns the JSON representation of GetNameOpsHashAtResult
func (r GetNameOpsHashAtResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNameOpsHashAtResult
func (r GetNameOpsHashAtResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// NamespaceTransaction is used to decode the get_namespace_blockchain_record return
type NamespaceTransaction struct {
Address string `json:"address"`
Base int `json:"base"`
BlockNumber int `json:"block_number"`
Buckets []int `json:"buckets"`
BurnAddress string `json:"burn_address"`
Coeff int `json:"coeff"`
ConsensusHash string `json:"consensus_hash"`
HistorySnapshot bool `json:"history_snapshot"`
Lifetime int `json:"lifetime"`
NamespaceID string `json:"namespace_id"`
NonalphaDiscount int `json:"nonalpha_discount"`
NoVowelDiscount int `json:"no_vowel_discount"`
Op string `json:"op"`
Opcode string `json:"opcode"`
OpFee int64 `json:"op_fee"`
PreorderHash string `json:"preorder_hash"`
Recipient string `json:"recipient"`
RecipientAddress string `json:"recipient_address"`
RevealBlock int `json:"reveal_block"`
Sender string `json:"sender"`
SenderPubkey string `json:"sender_pubkey"`
Txid string `json:"txid"`
Version int `json:"version"`
Vtxindex int `json:"vtxindex"`
}
// JSON returns the JSON representation of Transaction
func (r NamespaceTransaction) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of Transaction
func (r NamespaceTransaction) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNamespaceBlockchainRecordResult is the go represenation of the get_namespace_blockchain_record rpc method
type GetNamespaceBlockchainRecordResult struct {
Status bool `json:"status"`
Record struct {
BlockNumber int `json:"block_number"`
NonalphaDiscount int `json:"nonalpha_discount"`
NamespaceID string `json:"namespace_id"`
RevealBlock int `json:"reveal_block"`
Buckets []int `json:"buckets"`
Base int `json:"base"`
Address string `json:"address"`
Ready bool `json:"ready"`
Lifetime int `json:"lifetime"`
Recipient string `json:"recipient"`
OpFee int64 `json:"op_fee"`
Sender string `json:"sender"`
RecipientAddress string `json:"recipient_address"`
SenderPubkey string `json:"sender_pubkey"`
ReadyBlock int `json:"ready_block"`
Coeff int `json:"coeff"`
Txid string `json:"txid"`
Version int `json:"version"`
Opcode string `json:"opcode"`
NoVowelDiscount int `json:"no_vowel_discount"`
PreorderHash string `json:"preorder_hash"`
History map[int][]NamespaceTransaction `json:"history"`
Vtxindex int `json:"vtxindex"`
Op string `json:"op"`
} `json:"record"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of GetNamespaceBlockchainRecordResult
func (r GetNamespaceBlockchainRecordResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNamespaceBlockchainRecordResult
func (r GetNamespaceBlockchainRecordResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetZonefilesResult is the go represenation of the get_zonfiles rpc method
type GetZonefilesResult struct {
Status bool `json:"status"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
Zonefiles map[string]string `json:"zonefiles"`
}
// Decode is an affordance that returns the results in map[zonefileHash]zonefile
func (r GetZonefilesResult) Decode() map[string]string {
out := make(map[string]string)
for k := range r.Zonefiles {
dec, err := base64.StdEncoding.DecodeString(r.Zonefiles[k])
if err != nil {
log.Fatal(err)
}
out[k] = string(dec)
}
return out
}
// JSON returns the JSON representation of GetZonefilesResult
func (r GetZonefilesResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetZonefilesResult
func (r GetZonefilesResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetOpHistoryRowsResult is the go represenation of the get_zonfiles rpc method
// NOTE: The HistoryData field is a Transaction, but the JSON is returned from blockstack-core escaped
// TODO: Get this fixed server-side
type GetOpHistoryRowsResult struct {
Status bool `json:"status"`
HistoryRows []struct {
BlockID int `json:"block_id"`
Op string `json:"op"`
HistoryID string `json:"history_id"`
HistoryData string `json:"history_data"`
Vtxindex int `json:"vtxindex"`
Txid string `json:"txid"`
} `json:"history_rows"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of GetOpHistoryRowsResult
func (r GetOpHistoryRowsResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetOpHistoryRowsResult
func (r GetOpHistoryRowsResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// CountResult is the go represenation of the
// get_num_names, get_num_names_in_namespace, get_num_nameops_affected_at, get_num_op_history_rows
// rpc methods
type CountResult struct {
Status bool `json:"status"`
Count int `json:"count"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of CountResult
func (r CountResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of CountResult
func (r CountResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetNameOpsAffectedAtResult is the go represenation of the get_nameops_affected_at rpc method
type GetNameOpsAffectedAtResult struct {
Status bool `json:"status"`
Nameops []Transaction `json:"nameops"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of GetNameOpsAffectedAtResult
func (r GetNameOpsAffectedAtResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetNameOpsAffectedAtResult
func (r GetNameOpsAffectedAtResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// GetConsensusHashesResult is the go representation of the get_consensus_hashes rpc method
type GetConsensusHashesResult struct {
Status bool `json:"status"`
ConsensusHashes map[int]string `json:"consensus_hashes"`
Lastblock int `json:"lastblock"`
Indexing bool `json:"indexing"`
}
// JSON returns the JSON representation of GetConsensusHashesResult
func (r GetConsensusHashesResult) JSON() string {
byt, err := json.Marshal(r)
if err != nil {
log.Fatal(err)
}
return string(byt)
}
// PrettyJSON returns the Pretty Printed JSON representation of GetConsensusHashesResult
func (r GetConsensusHashesResult) PrettyJSON() string {
byt, err := json.MarshalIndent(r, "", " ")
if err != nil {
log.Fatal(err)
}
return string(byt)
}