-
Notifications
You must be signed in to change notification settings - Fork 2
/
verus_multichain.go
1351 lines (1231 loc) · 50.2 KB
/
verus_multichain.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
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright © 2018-2020 Satinderjit Singh.
//
// See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at
// the top-level directory of this distribution for the individual copyright
// holder information and the developer policies on copyright and licensing.
//
// Unless otherwise agreed in a custom licensing agreement, no part of the
// kmdgo software, including this file may be copied, modified, propagated.
// or distributed except according to the terms contained in the LICENSE file
//
// Removal or modification of this copyright notice is prohibited.
package kmdgo
import (
"encoding/json"
"errors"
"fmt"
"log"
)
// GetCurrency type
type GetCurrency struct {
Result struct {
Name string `json:"name"`
Version int `json:"version"`
Options int `json:"options"`
Parent string `json:"parent"`
Systemid string `json:"systemid"`
Currencyid string `json:"currencyid"`
Notarizationprotocol int `json:"notarizationprotocol"`
Proofprotocol int `json:"proofprotocol"`
Idregistrationprice int `json:"idregistrationprice"`
Idreferrallevels int `json:"idreferrallevels"`
Minnotariesconfirm int `json:"minnotariesconfirm"`
Billingperiod int `json:"billingperiod"`
Notarizationreward int `json:"notarizationreward"`
Startblock int `json:"startblock"`
Endblock int `json:"endblock"`
Currencies []string `json:"currencies"`
Weights []float64 `json:"weights"`
Conversions []float64 `json:"conversions"`
Initialsupply float64 `json:"initialsupply"`
Prelaunchcarveout float64 `json:"prelaunchcarveout"`
Initialcontributions []float64 `json:"initialcontributions"`
Preconversions []float64 `json:"preconversions"`
Eras []interface{} `json:"eras"`
Definitiontxid string `json:"definitiontxid"`
Bestcurrencystate struct {
Flags int `json:"flags"`
Currencyid string `json:"currencyid"`
Reservecurrencies []struct {
Currencyid string `json:"currencyid"`
Weight float64 `json:"weight"`
Reserves float64 `json:"reserves"`
Priceinreserve float64 `json:"priceinreserve"`
} `json:"reservecurrencies"`
Initialsupply float64 `json:"initialsupply"`
Emitted float64 `json:"emitted"`
Supply float64 `json:"supply"`
Currencies map[string]Currencies `json:"currencies"`
Nativefees int `json:"nativefees"`
Nativeconversionfees int `json:"nativeconversionfees"`
} `json:"bestcurrencystate"`
} `json:"result"`
Error Error `json:"error"`
ID string `json:"id"`
}
// Currencies type
type Currencies struct {
Reservein float64 `json:"reservein"`
Nativein float64 `json:"nativein"`
Reserveout float64 `json:"reserveout"`
Lastconversionprice float64 `json:"lastconversionprice"`
Viaconversionprice float64 `json:"viaconversionprice"`
Fees float64 `json:"fees"`
Conversionfees float64 `json:"conversionfees"`
}
// GetCurrency returns a complete definition for any given chain if it is registered on the blockchain. If the chain requested is NULL, chain definition of the current chain is returned.
//
// getcurrency "chainname"
//
// Arguments
// 1. "chainname" (string, optional) name of the chain to look for. no parameter returns current chain in daemon.
func (appName AppType) GetCurrency(params APIParams) (GetCurrency, error) {
// fmt.Println("params[0]", params[0])
paramsJSON, _ := json.Marshal(params)
// fmt.Println(string(paramsJSON))
query := APIQuery{
Method: `getcurrency`,
Params: string(paramsJSON),
}
// fmt.Println(query)
var getCrncy GetCurrency
getCrncyJSON := appName.APICall(&query)
if getCrncyJSON == "EMPTY RPC INFO" {
return getCrncy, errors.New("EMPTY RPC INFO")
}
var result APIResult
json.Unmarshal([]byte(getCrncyJSON), &result)
if result.Result == nil {
answerError, err := json.Marshal(result.Error)
if err != nil {
}
json.Unmarshal([]byte(getCrncyJSON), &getCrncy)
return getCrncy, errors.New(string(answerError))
}
json.Unmarshal([]byte(getCrncyJSON), &getCrncy)
return getCrncy, nil
}
// GetCurrencyState type
type GetCurrencyState struct {
Result struct {
Height int `json:"height"`
Blocktime int `json:"blocktime"`
Currencystate struct {
Flags int `json:"flags"`
Currencyid string `json:"currencyid"`
Initialsupply float64 `json:"initialsupply"`
Emitted float64 `json:"emitted"`
Supply float64 `json:"supply"`
Currencies struct {
} `json:"currencies"`
Nativefees int `json:"nativefees"`
Nativeconversionfees int `json:"nativeconversionfees"`
} `json:"currencystate"`
} `json:"result"`
Error Error `json:"error"`
ID string `json:"id"`
}
// GetCurrencyState returns the total amount of preconversions that have been confirmed on the blockchain for the specified chain.
//
// getcurrencystate "n"
//
// Arguments
// "n" or "m,n" or "m,n,o" (int or string, optional) height or inclusive range with optional step at which to get the currency state. If not specified, the latest currency state and height is returned
//
func (appName AppType) GetCurrencyState(params APIParams) (GetCurrencyState, error) {
// fmt.Println("params[0]", params[0])
paramsJSON, _ := json.Marshal(params)
// fmt.Println(string(paramsJSON))
query := APIQuery{
Method: `getcurrencystate`,
Params: string(paramsJSON),
}
// fmt.Println(query)
var getCurSt GetCurrencyState
getCurStJSON := appName.APICall(&query)
if getCurStJSON == "EMPTY RPC INFO" {
return getCurSt, errors.New("EMPTY RPC INFO")
}
var result APIResult
json.Unmarshal([]byte(getCurStJSON), &result)
if result.Result == nil {
answerError, err := json.Marshal(result.Error)
if err != nil {
}
json.Unmarshal([]byte(getCurStJSON), &getCurSt)
return getCurSt, errors.New(string(answerError))
}
json.Unmarshal([]byte(getCurStJSON), &getCurSt)
return getCurSt, nil
}
// CurrencyInfo type
type CurrencyInfo struct {
Name string `json:"name"`
Version int `json:"version"`
Options int `json:"options"`
Parent string `json:"parent"`
Systemid string `json:"systemid"`
Currencyid string `json:"currencyid"`
Notarizationprotocol int `json:"notarizationprotocol"`
Proofprotocol int `json:"proofprotocol"`
Idregistrationprice int `json:"idregistrationprice"`
Idreferrallevels int `json:"idreferrallevels"`
Minnotariesconfirm int `json:"minnotariesconfirm"`
Billingperiod int `json:"billingperiod"`
Notarizationreward int `json:"notarizationreward"`
Startblock int `json:"startblock"`
Endblock int `json:"endblock"`
Currencies []string `json:"currencies"`
Weights []float64 `json:"weights"`
Conversions []float64 `json:"conversions"`
Initialsupply float64 `json:"initialsupply"`
Prelaunchcarveout float64 `json:"prelaunchcarveout"`
Initialcontributions []float64 `json:"initialcontributions"`
Preconversions []float64 `json:"preconversions"`
Eras []interface{} `json:"eras"`
}
// GetCurrencyConverter type
type GetCurrencyConverter struct {
CurrencyInfo CurrencyInfo `json:"-"`
Lastnotarization struct {
Version int `json:"version"`
Currencyid string `json:"currencyid"`
Notaryaddress string `json:"notaryaddress"`
Notarizationheight int `json:"notarizationheight"`
Mmrroot string `json:"mmrroot"`
Notarizationprehash string `json:"notarizationprehash"`
Work string `json:"work"`
Stake string `json:"stake"`
Currencystate struct {
Flags int `json:"flags"`
Currencyid string `json:"currencyid"`
Reservecurrencies []struct {
Currencyid string `json:"currencyid"`
Weight float64 `json:"weight"`
Reserves float64 `json:"reserves"`
Priceinreserve float64 `json:"priceinreserve"`
} `json:"reservecurrencies"`
Initialsupply float64 `json:"initialsupply"`
Emitted float64 `json:"emitted"`
Supply float64 `json:"supply"`
Currencies map[string]Currencies `json:"currencies"`
Nativefees int64 `json:"nativefees"`
Nativeconversionfees int64 `json:"nativeconversionfees"`
} `json:"currencystate"`
Prevnotarization string `json:"prevnotarization"`
Prevheight int `json:"prevheight"`
Crossnotarization string `json:"crossnotarization"`
Crossheight int `json:"crossheight"`
Nodes []interface{} `json:"nodes"`
} `json:"lastnotarization"`
Multifractional struct {
Name string `json:"name"`
Version int `json:"version"`
Options int `json:"options"`
Parent string `json:"parent"`
Systemid string `json:"systemid"`
Currencyid string `json:"currencyid"`
Notarizationprotocol int `json:"notarizationprotocol"`
Proofprotocol int `json:"proofprotocol"`
Idregistrationprice int `json:"idregistrationprice"`
Idreferrallevels int `json:"idreferrallevels"`
Minnotariesconfirm int `json:"minnotariesconfirm"`
Billingperiod int `json:"billingperiod"`
Notarizationreward int `json:"notarizationreward"`
Startblock int `json:"startblock"`
Endblock int `json:"endblock"`
Currencies []string `json:"currencies"`
Weights []float64 `json:"weights"`
Conversions []float64 `json:"conversions"`
Initialsupply float64 `json:"initialsupply"`
Prelaunchcarveout float64 `json:"prelaunchcarveout"`
Initialcontributions []float64 `json:"initialcontributions"`
Preconversions []float64 `json:"preconversions"`
Eras []interface{} `json:"eras"`
} `json:"multifractional,omitempty"`
}
// GetCurrencyConverters array type
type GetCurrencyConverters struct {
Result []GetCurrencyConverter `json:"result"`
Error Error `json:"error"`
ID string `json:"id"`
}
// GetCurrencyConverters Retrieves all currencies that have at least 1000 VRSC in reserve, are >10% VRSC reserve ratio, and have all listed currencies as reserves
//
// getcurrencyconverters currency1 currency2
// Arguments
// ["currencyname" : "string", ...] (string list, one or more) all selected currencies are returned with their current state
// Result:
// "[{currency1}, {currency2}]" : "array of objects" (string) All currencies and the last notarization, which are valid converters.
//
// Examples:
// > verus getcurrencyconverters currency1 currency2 ...
func (appName AppType) GetCurrencyConverters(params APIParams) (GetCurrencyConverters, error) {
// fmt.Println("params[0]", params[0])
paramsJSON, _ := json.Marshal(params)
// fmt.Println(string(paramsJSON))
query := APIQuery{
Method: `getcurrencyconverters`,
Params: string(paramsJSON),
}
// fmt.Println(query)
var getCurCovrts GetCurrencyConverters
getCurCovrtsJSON := appName.APICall(&query)
if getCurCovrtsJSON == "EMPTY RPC INFO" {
return getCurCovrts, errors.New("EMPTY RPC INFO")
}
var result APIResult
json.Unmarshal([]byte(getCurCovrtsJSON), &result)
if result.Result == nil {
answerError, err := json.Marshal(result.Error)
if err != nil {
}
json.Unmarshal([]byte(getCurCovrtsJSON), &getCurCovrts)
return getCurCovrts, errors.New(string(answerError))
}
json.Unmarshal([]byte(getCurCovrtsJSON), &getCurCovrts)
// fmt.Println(getCurCovrtsJSON)
var f interface{}
// m := f.(map[string]interface{})
err := json.Unmarshal([]byte(getCurCovrtsJSON), &f)
if err != nil {
log.Printf("%v", err)
}
// fmt.Printf("%+v\n", f)
// fmt.Printf("%T\n", f)
m := f.(map[string]interface{})
var n interface{}
for k, v := range m {
// fmt.Printf("k -- %+v\n", k)
// fmt.Println("v --- ", v)
if k == "result" {
n = v
}
}
// fmt.Println("n -- ", n)
o := n.([]interface{})
for k, v := range o {
// fmt.Printf("k -- %+v\n", k)
// fmt.Println("v --- ", v)
p := v.(map[string]interface{})
if _, ok := v.(map[string]interface{})["lastnotarization"]; ok {
// fmt.Println("lastnotarization ---", val)
delete(v.(map[string]interface{}), "lastnotarization")
}
if _, ok := v.(map[string]interface{})["multifractional"]; ok {
// fmt.Println("multifractional ---", val)
delete(v.(map[string]interface{}), "multifractional")
}
for pk, pv := range p {
// fmt.Printf("pk - %+v\n", pk)
// fmt.Printf("pv - %T\n", pv)
switch vv := pv.(type) {
case string:
fmt.Println(pk, "is string", vv)
case float64:
fmt.Println(pk, "is float64", vv)
case []interface{}:
fmt.Println(pk, "is an array:")
for i, u := range vv {
fmt.Println(i, u)
}
default:
// fmt.Println(pk, "is of a type I don't know how to handle")
// fmt.Printf("%T\n", vv)
// fmt.Printf("vv -- %+v\n", vv)
if val, ok := vv.(map[string]interface{})["name"]; ok {
// fmt.Println("name ---", val)
getCurCovrts.Result[0].CurrencyInfo.Name = val.(string)
}
if val, ok := vv.(map[string]interface{})["version"]; ok {
// fmt.Println("version ---", val)
getCurCovrts.Result[k].CurrencyInfo.Version = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["options"]; ok {
// fmt.Println("options ---", val)
getCurCovrts.Result[k].CurrencyInfo.Options = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["parent"]; ok {
// fmt.Println("parent ---", val)
getCurCovrts.Result[k].CurrencyInfo.Parent = val.(string)
}
if val, ok := vv.(map[string]interface{})["systemid"]; ok {
// fmt.Println("systemid ---", val)
getCurCovrts.Result[k].CurrencyInfo.Systemid = val.(string)
}
if val, ok := vv.(map[string]interface{})["currencyid"]; ok {
// fmt.Println("currencyid ---", val)
getCurCovrts.Result[k].CurrencyInfo.Currencyid = val.(string)
}
if val, ok := vv.(map[string]interface{})["notarizationprotocol"]; ok {
// fmt.Println("notarizationprotocol ---", val)
getCurCovrts.Result[k].CurrencyInfo.Notarizationprotocol = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["proofprotocol"]; ok {
// fmt.Println("proofprotocol ---", val)
getCurCovrts.Result[k].CurrencyInfo.Proofprotocol = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["idregistrationprice"]; ok {
// fmt.Println("idregistrationprice ---", val)
getCurCovrts.Result[k].CurrencyInfo.Idregistrationprice = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["idreferrallevels"]; ok {
// fmt.Println("idreferrallevels ---", val)
getCurCovrts.Result[k].CurrencyInfo.Idreferrallevels = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["minnotariesconfirm"]; ok {
// fmt.Println("minnotariesconfirm ---", val)
getCurCovrts.Result[k].CurrencyInfo.Minnotariesconfirm = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["billingperiod"]; ok {
// fmt.Println("billingperiod ---", val)
getCurCovrts.Result[k].CurrencyInfo.Billingperiod = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["notarizationreward"]; ok {
// fmt.Println("notarizationreward ---", val)
getCurCovrts.Result[k].CurrencyInfo.Notarizationreward = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["startblock"]; ok {
// fmt.Println("startblock ---", val)
getCurCovrts.Result[k].CurrencyInfo.Startblock = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["endblock"]; ok {
// fmt.Println("endblock ---", val)
getCurCovrts.Result[k].CurrencyInfo.Endblock = int(val.(float64))
}
if val, ok := vv.(map[string]interface{})["currencies"]; ok {
// fmt.Printf("currencies type --- %T\n", val)
// fmt.Println("currencies ---", val)
var _tmpCurrencies []string
for _, curv := range val.([]interface{}) {
// fmt.Println(curv)
// fmt.Printf("curv -- %T\n", curv)
_tmpCurrencies = append(_tmpCurrencies, fmt.Sprintf("%v", curv))
}
// fmt.Printf("%T\n", _tmpCurrencies)
// fmt.Printf("%+v\n", _tmpCurrencies)
getCurCovrts.Result[k].CurrencyInfo.Currencies = _tmpCurrencies
}
if val, ok := vv.(map[string]interface{})["weights"]; ok {
// fmt.Println("weights ---", val)
var _tmpWeights []float64
for _, wghtv := range val.([]interface{}) {
// fmt.Println(wghtv)
// fmt.Printf("wghtv -- %T\n", wghtv)
_tmpWeights = append(_tmpWeights, wghtv.(float64))
}
// fmt.Printf("%T\n", _tmpWeights)
// fmt.Printf("%+v\n", _tmpWeights)
getCurCovrts.Result[k].CurrencyInfo.Weights = _tmpWeights
}
if val, ok := vv.(map[string]interface{})["conversions"]; ok {
// fmt.Println("conversions ---", val)
var _tmpConversions []float64
for _, cnvrsv := range val.([]interface{}) {
// fmt.Println(cnvrsv)
// fmt.Printf("cnvrsv -- %T\n", cnvrsv)
_tmpConversions = append(_tmpConversions, cnvrsv.(float64))
}
// fmt.Printf("%T\n", _tmpConversions)
// fmt.Printf("%+v\n", _tmpConversions)
getCurCovrts.Result[k].CurrencyInfo.Conversions = _tmpConversions
}
if val, ok := vv.(map[string]interface{})["initialsupply"]; ok {
// fmt.Println("initialsupply ---", val)
getCurCovrts.Result[k].CurrencyInfo.Initialsupply = val.(float64)
}
if val, ok := vv.(map[string]interface{})["prelaunchcarveout"]; ok {
// fmt.Println("prelaunchcarveout ---", val)
getCurCovrts.Result[k].CurrencyInfo.Prelaunchcarveout = val.(float64)
}
if val, ok := vv.(map[string]interface{})["initialcontributions"]; ok {
// fmt.Println("initialcontributions ---", val)
var _tmpInitContri []float64
for _, initcontv := range val.([]interface{}) {
// fmt.Println(initcontv)
// fmt.Printf("initcontv -- %T\n", initcontv)
_tmpInitContri = append(_tmpInitContri, initcontv.(float64))
}
// fmt.Printf("%T\n", _tmpInitContri)
// fmt.Printf("%+v\n", _tmpInitContri)
getCurCovrts.Result[k].CurrencyInfo.Initialcontributions = _tmpInitContri
}
if val, ok := vv.(map[string]interface{})["preconversions"]; ok {
// fmt.Println("preconversions ---", val)
var _tmpPreConv []float64
for _, preconv := range val.([]interface{}) {
// fmt.Println(preconv)
// fmt.Printf("preconv -- %T\n", preconv)
_tmpPreConv = append(_tmpPreConv, preconv.(float64))
}
// fmt.Printf("%T\n", _tmpPreConv)
// fmt.Printf("%+v\n", _tmpPreConv)
getCurCovrts.Result[k].CurrencyInfo.Preconversions = _tmpPreConv
}
if val, ok := vv.(map[string]interface{})["eras"]; ok {
// fmt.Println("eras ---", val)
getCurCovrts.Result[k].CurrencyInfo.Eras = val.([]interface{})
}
}
}
}
return getCurCovrts, nil
}
// GetExports type
type GetExports struct {
Result []struct {
Blockheight int `json:"blockheight"`
Exportid string `json:"exportid"`
Description struct {
Version int `json:"version"`
Exportcurrencyid string `json:"exportcurrencyid"`
Numinputs int `json:"numinputs"`
Totalamounts map[string]float64 `json:"totalamounts"`
Totalfees map[string]float64 `json:"totalfees"`
} `json:"description"`
Transfers []struct {
Version int `json:"version"`
Currencyid string `json:"currencyid"`
Value float64 `json:"value"`
Flags int `json:"flags"`
Preconvert bool `json:"preconvert,omitempty"`
Fees float64 `json:"fees"`
Destinationcurrencyid string `json:"destinationcurrencyid"`
Destination string `json:"destination"`
Feeoutput bool `json:"feeoutput,omitempty"`
} `json:"transfers"`
} `json:"result"`
Error Error `json:"error"`
ID string `json:"id"`
}
// GetExports returns all pending export transfers that are not yet provable with confirmed notarizations.
// These are the transactions that are crossing from one to another currency. In other words: conversions
// It's output behaves like a mempool transactions, and the output of results disappear after a while, and new ones shows up.
//
// getexports "chainname"
//
// Arguments
// 1. "chainname" (string, optional) name of the chain to look for. no parameter returns current chain in daemon.
//
// Example Result:
// [
// {
// "blockheight": 144,
// "exportid": "ea087427e81352bd84887ff90d370e8cf5c51b61f694c673b75b64696391d777",
// "description": {
// "version": 1,
// "exportcurrencyid": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt",
// "numinputs": 2,
// "totalamounts": {
// "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3": 94.15731371,
// "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq": 1000250.06291562
// },
// "totalfees": {
// "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3": 0.02353932,
// "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq": 250.06291562
// }
// },
// "transfers": [
// {
// "version": 1,
// "currencyid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "value": 1000250.06251562,
// "flags": 4101,
// "preconvert": true,
// "fees": 0.0002,
// "destinationcurrencyid": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt",
// "destination": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt"
// },
// {
// "version": 1,
// "currencyid": "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3",
// "value": 94.15731371,
// "flags": 4101,
// "preconvert": true,
// "fees": 0.0002,
// "destinationcurrencyid": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt",
// "destination": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt"
// },
// {
// "version": 1,
// "currencyid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "value": 0,
// "flags": 9,
// "feeoutput": true,
// "fees": 0,
// "destinationcurrencyid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "destination": "RCdrw4BL7B8rKJ2iQqftvBA4SAtwGA3eBc"
// }
// ]
// },
// {},
// ...
// ]
//
// Examples:
// > verus getexports "chainname"
// > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getexports", "params": ["chainname"] }' -H 'content-type: text/plain;' http://127.0.0.1:27486/
func (appName AppType) GetExports(params APIParams) (GetExports, error) {
// fmt.Println("params[0]", params[0])
paramsJSON, _ := json.Marshal(params)
// fmt.Println(string(paramsJSON))
query := APIQuery{
Method: `getexports`,
Params: string(paramsJSON),
}
// fmt.Println(query)
var getExp GetExports
getExpJSON := appName.APICall(&query)
if getExpJSON == "EMPTY RPC INFO" {
return getExp, errors.New("EMPTY RPC INFO")
}
var result APIResult
json.Unmarshal([]byte(getExpJSON), &result)
if result.Result == nil {
answerError, err := json.Marshal(result.Error)
if err != nil {
}
json.Unmarshal([]byte(getExpJSON), &getExp)
return getExp, errors.New(string(answerError))
}
json.Unmarshal([]byte(getExpJSON), &getExp)
return getExp, nil
}
// GetImports type
type GetImports struct {
Result []struct {
Blockheight int `json:"blockheight"`
Importid string `json:"importid"`
Description struct {
Version int `json:"version"`
Sourcesystemid string `json:"sourcesystemid"`
Importcurrencyid string `json:"importcurrencyid"`
Valuein map[string]float64 `json:"valuein"`
Tokensout map[string]float64 `json:"tokensout"`
} `json:"description"`
Transfers []struct {
Version int `json:"version"`
Currencyid string `json:"currencyid"`
Value float64 `json:"value"`
Flags int `json:"flags"`
Preconvert bool `json:"preconvert,omitempty"`
Fees float64 `json:"fees"`
Destinationcurrencyid string `json:"destinationcurrencyid"`
Destination string `json:"destination"`
Feeoutput bool `json:"feeoutput,omitempty"`
} `json:"transfers"`
} `json:"result"`
Error Error `json:"error"`
ID string `json:"id"`
}
// GetImports returns all imports from a specific chain.
//
// getimports "chainname"
//
// Arguments
// 1. "chainname" (string, optional) name of the chain to look for. no parameter returns current chain in daemon.
//
// Example Result:
// [
// {
// "blockheight": 149,
// "importid": "c5b5aa070b57b6599ea8714692187f06261c215c641d13e06dacd74ed40272a3",
// "description": {
// "version": 1,
// "sourcesystemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "importcurrencyid": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt",
// "valuein": {
// "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt": 1999933.86859995,
// "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3": 94.15731371,
// "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq": 1000500.06191861
// },
// "tokensout": {
// "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3": 94.15731371
// }
// },
// "transfers": [
// {
// "version": 1,
// "currencyid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "value": 1000250.06251562,
// "flags": 4101,
// "preconvert": true,
// "fees": 0.0002,
// "destinationcurrencyid": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt",
// "destination": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt"
// },
// {
// "version": 1,
// "currencyid": "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3",
// "value": 94.15731371,
// "flags": 4101,
// "preconvert": true,
// "fees": 0.0002,
// "destinationcurrencyid": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt",
// "destination": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt"
// },
// {
// "version": 1,
// "currencyid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "value": 0,
// "flags": 9,
// "feeoutput": true,
// "fees": 0,
// "destinationcurrencyid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "destination": "RCdrw4BL7B8rKJ2iQqftvBA4SAtwGA3eBc"
// }
// ]
// },
// {},
// ...
// ]
//
// Examples:
// > verus getimports "chainname"
// > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getimports", "params": ["chainname"] }' -H 'content-type: text/plain;' http://127.0.0.1:27486/
func (appName AppType) GetImports(params APIParams) (GetImports, error) {
// fmt.Println("params[0]", params[0])
paramsJSON, _ := json.Marshal(params)
// fmt.Println(string(paramsJSON))
query := APIQuery{
Method: `getimports`,
Params: string(paramsJSON),
}
// fmt.Println(query)
var getImp GetImports
getImpJSON := appName.APICall(&query)
if getImpJSON == "EMPTY RPC INFO" {
return getImp, errors.New("EMPTY RPC INFO")
}
var result APIResult
json.Unmarshal([]byte(getImpJSON), &result)
if result.Result == nil {
answerError, err := json.Marshal(result.Error)
if err != nil {
}
json.Unmarshal([]byte(getImpJSON), &getImp)
return getImp, errors.New(string(answerError))
}
json.Unmarshal([]byte(getImpJSON), &getImp)
return getImp, nil
}
// GetInitialCurrencyState type
type GetInitialCurrencyState struct {
Result struct {
Flags int `json:"flags"`
Currencyid string `json:"currencyid"`
Reservecurrencies []struct {
Currencyid string `json:"currencyid"`
Weight float64 `json:"weight"`
Reserves float64 `json:"reserves"`
Priceinreserve float64 `json:"priceinreserve"`
} `json:"reservecurrencies"`
Initialsupply float64 `json:"initialsupply"`
Emitted float64 `json:"emitted"`
Supply float64 `json:"supply"`
Currencies map[string]Currencies `json:"currencies"`
Nativefees int64 `json:"nativefees"`
Nativeconversionfees int64 `json:"nativeconversionfees"`
} `json:"result"`
Error Error `json:"error"`
ID string `json:"id"`
}
// GetInitialCurrencyState returns the total amount of preconversions that have been confirmed on the blockchain for the specified PBaaS chain.
// This should be used to get information about chains that are not this chain, but are being launched by it.
//
// getinitialcurrencystate "name"
//
// Arguments
// "name" (string, required) name or chain ID of the chain to get the export transactions for
//
// Example Result:
// {
// "flags": 11,
// "currencyid": "i84mndBk2Znydpgm9T9pTjVvBnHkhErzLt",
// "reservecurrencies": [
// {
// "currencyid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq",
// "weight": 0.50000000,
// "reserves": 999750.00099701,
// "priceinreserve": 0.99975000
// },
// {
// "currencyid": "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3",
// "weight": 0.50000000,
// "reserves": 94.15731371,
// "priceinreserve": 0.00009415
// }
// ],
// "initialsupply": 2000000.00000000,
// "emitted": 0.00000000,
// "supply": 2000000.00000000,
// "currencies": {
// "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq": {
// "reservein": 1000000.00000000,
// "nativein": 0.00000000,
// "reserveout": 249.99900299,
// "lastconversionprice": 1.00000000,
// "viaconversionprice": 0.99981249,
// "fees": 250.06291562,
// "conversionfees": 250.06251562
// },
// "iBBRjDbPf3wdFpghLotJQ3ESjtPBxn6NS3": {
// "reservein": 94.15731371,
// "nativein": 0.00000000,
// "reserveout": 0.00000000,
// "lastconversionprice": 0.00009414,
// "viaconversionprice": 0.00009414,
// "fees": 0.02353932,
// "conversionfees": 0.02353932
// }
// },
// "nativefees": 50006191861,
// "nativeconversionfees": 50006151861
// }
//
// Examples:
// > verus getinitialcurrencystate name
// > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinitialcurrencystate", "params": [name] }' -H 'content-type: text/plain;' http://127.0.0.1:27486/
func (appName AppType) GetInitialCurrencyState(params APIParams) (GetInitialCurrencyState, error) {
// fmt.Println("params[0]", params[0])
paramsJSON, _ := json.Marshal(params)
// fmt.Println(string(paramsJSON))
query := APIQuery{
Method: `getinitialcurrencystate`,
Params: string(paramsJSON),
}
// fmt.Println(query)
var getInCurSt GetInitialCurrencyState
getInCurStJSON := appName.APICall(&query)
if getInCurStJSON == "EMPTY RPC INFO" {
return getInCurSt, errors.New("EMPTY RPC INFO")
}
var result APIResult
json.Unmarshal([]byte(getInCurStJSON), &result)
if result.Result == nil {
answerError, err := json.Marshal(result.Error)
if err != nil {
}
json.Unmarshal([]byte(getInCurStJSON), &getInCurSt)
return getInCurSt, errors.New(string(answerError))
}
json.Unmarshal([]byte(getInCurStJSON), &getInCurSt)
return getInCurSt, nil
}
// GetLastImportin type
type GetLastImportin struct {
Result struct {
Lastimporttransaction string `json:"lastimporttransaction"`
Lastconfirmednotarization string `json:"lastconfirmednotarization"`
Importtxtemplate string `json:"importtxtemplate"`
Nativeimportavailable int64 `json:"nativeimportavailable"`
Tokenimportavailable map[string]float64 `json:"tokenimportavailable"`
} `json:"result"`
Error Error `json:"error"`
ID string `json:"id"`
}
// GetLastImportin returns the last import transaction from the chain specified and a blank transaction template to use when making new
// import transactions. Since the typical use for this call is to make new import transactions from the other chain that will be then
// broadcast to this chain, we include the template by default.
//
// getlastimportin "fromname"
//
// Arguments
// "fromname" (string, required) name of the chain to get the last import transaction in from
//
// Result:
// {
// "lastimporttransaction": "hex" Hex encoded serialized import transaction
// "lastconfirmednotarization" : "hex" Hex encoded last confirmed notarization transaction
// "importtxtemplate": "hex" Hex encoded import template for new import transactions
// "nativeimportavailable": "amount" Total amount of native import currency available to import as native
// "tokenimportavailable": "array" ([{"currencyid":amount},..], required) tokens available to import, if controlled by this chain
// }
//
// Examples:
// > verus getlastimportin jsondefinition
// > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getlastimportin", "params": [jsondefinition] }' -H 'content-type: text/plain;' http://127.0.0.1:27486/
func (appName AppType) GetLastImportin(params APIParams) (GetLastImportin, error) {
// fmt.Println("params[0]", params[0])
paramsJSON, _ := json.Marshal(params)
// fmt.Println(string(paramsJSON))
query := APIQuery{
Method: `getlastimportin`,
Params: string(paramsJSON),
}
// fmt.Println(query)
var getLastImpIn GetLastImportin
getLastImpInJSON := appName.APICall(&query)
if getLastImpInJSON == "EMPTY RPC INFO" {
return getLastImpIn, errors.New("EMPTY RPC INFO")
}
var result APIResult
json.Unmarshal([]byte(getLastImpInJSON), &result)
if result.Result == nil {
answerError, err := json.Marshal(result.Error)
if err != nil {
}
json.Unmarshal([]byte(getLastImpInJSON), &getLastImpIn)
return getLastImpIn, errors.New(string(answerError))
}
json.Unmarshal([]byte(getLastImpInJSON), &getLastImpIn)
return getLastImpIn, nil
}
// GetNotarizationData type
type GetNotarizationData struct {
Result struct {
Version int `json:"version"`
Notarizations []struct {
Index int `json:"index"`
Txid string `json:"txid"`
Notarization struct {
Version int `json:"version"`
Currencyid string `json:"currencyid"`
Notaryaddress string `json:"notaryaddress"`
Notarizationheight int `json:"notarizationheight"`
Mmrroot string `json:"mmrroot"`
Notarizationprehash string `json:"notarizationprehash"`
Work string `json:"work"`
Stake string `json:"stake"`
Currencystate struct {
Flags int `json:"flags"`
Currencyid string `json:"currencyid"`
Reservecurrencies []struct {
Currencyid string `json:"currencyid"`
Weight float64 `json:"weight"`
Reserves float64 `json:"reserves"`
Priceinreserve float64 `json:"priceinreserve"`
} `json:"reservecurrencies"`
Initialsupply float64 `json:"initialsupply"`
Emitted float64 `json:"emitted"`
Supply float64 `json:"supply"`
Currencies map[string]Currencies `json:"currencies"`
Nativefees int `json:"nativefees"`
Nativeconversionfees int `json:"nativeconversionfees"`
} `json:"currencystate"`
Prevnotarization string `json:"prevnotarization"`
Prevheight int `json:"prevheight"`
Crossnotarization string `json:"crossnotarization"`
Crossheight int `json:"crossheight"`
Nodes []interface{} `json:"nodes"`
} `json:"notarization"`