This repository was archived by the owner on Aug 30, 2024. It is now read-only.
forked from drivechain-project/diff-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainchainUIDIFF.html
2393 lines (2370 loc) · 137 KB
/
mainchainUIDIFF.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style type="text/css">
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
body .hll { background-color: #ffffcc }
body { background: #ffffff; }
body .c { color: #999988; font-style: italic } /* Comment */
body .err { color: #a61717; background-color: #e3d2d2 } /* Error */
body .k { font-weight: bold } /* Keyword */
body .o { font-weight: bold } /* Operator */
body .ch { color: #999988; font-style: italic } /* Comment.Hashbang */
body .cm { color: #999988; font-style: italic } /* Comment.Multiline */
body .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
body .cpf { color: #999988; font-style: italic } /* Comment.PreprocFile */
body .c1 { color: #999988; font-style: italic } /* Comment.Single */
body .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
body .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
body .ge { font-style: italic } /* Generic.Emph */
body .gr { color: #aa0000 } /* Generic.Error */
body .gh { color: #999999 } /* Generic.Heading */
body .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
body .go { color: #888888 } /* Generic.Output */
body .gp { color: #555555 } /* Generic.Prompt */
body .gs { font-weight: bold } /* Generic.Strong */
body .gu { color: #aaaaaa } /* Generic.Subheading */
body .gt { color: #aa0000 } /* Generic.Traceback */
body .kc { font-weight: bold } /* Keyword.Constant */
body .kd { font-weight: bold } /* Keyword.Declaration */
body .kn { font-weight: bold } /* Keyword.Namespace */
body .kp { font-weight: bold } /* Keyword.Pseudo */
body .kr { font-weight: bold } /* Keyword.Reserved */
body .kt { color: #445588; font-weight: bold } /* Keyword.Type */
body .m { color: #009999 } /* Literal.Number */
body .s { color: #bb8844 } /* Literal.String */
body .na { color: #008080 } /* Name.Attribute */
body .nb { color: #999999 } /* Name.Builtin */
body .nc { color: #445588; font-weight: bold } /* Name.Class */
body .no { color: #008080 } /* Name.Constant */
body .ni { color: #800080 } /* Name.Entity */
body .ne { color: #990000; font-weight: bold } /* Name.Exception */
body .nf { color: #990000; font-weight: bold } /* Name.Function */
body .nn { color: #555555 } /* Name.Namespace */
body .nt { color: #000080 } /* Name.Tag */
body .nv { color: #008080 } /* Name.Variable */
body .ow { font-weight: bold } /* Operator.Word */
body .w { color: #bbbbbb } /* Text.Whitespace */
body .mb { color: #009999 } /* Literal.Number.Bin */
body .mf { color: #009999 } /* Literal.Number.Float */
body .mh { color: #009999 } /* Literal.Number.Hex */
body .mi { color: #009999 } /* Literal.Number.Integer */
body .mo { color: #009999 } /* Literal.Number.Oct */
body .sa { color: #bb8844 } /* Literal.String.Affix */
body .sb { color: #bb8844 } /* Literal.String.Backtick */
body .sc { color: #bb8844 } /* Literal.String.Char */
body .dl { color: #bb8844 } /* Literal.String.Delimiter */
body .sd { color: #bb8844 } /* Literal.String.Doc */
body .s2 { color: #bb8844 } /* Literal.String.Double */
body .se { color: #bb8844 } /* Literal.String.Escape */
body .sh { color: #bb8844 } /* Literal.String.Heredoc */
body .si { color: #bb8844 } /* Literal.String.Interpol */
body .sx { color: #bb8844 } /* Literal.String.Other */
body .sr { color: #808000 } /* Literal.String.Regex */
body .s1 { color: #bb8844 } /* Literal.String.Single */
body .ss { color: #bb8844 } /* Literal.String.Symbol */
body .bp { color: #999999 } /* Name.Builtin.Pseudo */
body .fm { color: #990000; font-weight: bold } /* Name.Function.Magic */
body .vc { color: #008080 } /* Name.Variable.Class */
body .vg { color: #008080 } /* Name.Variable.Global */
body .vi { color: #008080 } /* Name.Variable.Instance */
body .vm { color: #008080 } /* Name.Variable.Magic */
body .il { color: #009999 } /* Literal.Number.Integer.Long */
</style>
</head>
<body>
<h2></h2>
<div class="highlight"><pre><span></span><span class="gh">diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp</span>
<span class="gh">index 99c1242d8..861516971 100644</span>
<span class="gd">--- a/src/rpc/client.cpp</span>
<span class="gi">+++ b/src/rpc/client.cpp</span>
<span class="gu">@@ -129,6 +129,16 @@ static const CRPCConvertParam vRPCConvertParams[] =</span>
{ "logging", 1, "exclude" },
{ "disconnectnode", 1, "nodeid" },
{ "addwitnessaddress", 1, "p2sh" },
<span class="gi">+ { "createcriticaldatatx", 0, "amount" },</span>
<span class="gi">+ { "createcriticaldatatx", 1, "height" },</span>
<span class="gi">+ { "createbmmcriticaldatatx", 0, "amount" },</span>
<span class="gi">+ { "createbmmcriticaldatatx", 1, "height" },</span>
<span class="gi">+ { "createbmmcriticaldatatx", 3, "nsidechain" },</span>
<span class="gi">+ { "createbmmcriticaldatatx", 4, "ndag" },</span>
<span class="gi">+ { "listsidechaindeposits", 0, "nsidechain" },</span>
<span class="gi">+ { "receivewtprime", 0, "nsidechain" },</span>
<span class="gi">+ { "receivewtprimeupdate", 0, "height" },</span>
<span class="gi">+ { "receivewtprimeupdate", 1, "update" },</span>
// Echo with conversion (For testing only)
{ "echojson", 0, "arg0" },
{ "echojson", 1, "arg1" },
<span class="gh">diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp</span>
old mode 100644
new mode 100755
<span class="gh">index e772f5653..9ed4a9267</span>
<span class="gd">--- a/src/rpc/misc.cpp</span>
<span class="gi">+++ b/src/rpc/misc.cpp</span>
<span class="gu">@@ -6,20 +6,26 @@</span>
#include <base58.h>
#include <chain.h>
#include <clientversion.h>
<span class="gi">+#include <consensus/validation.h></span>
#include <core_io.h>
#include <crypto/ripemd160.h>
<span class="gd">-#include <init.h></span>
<span class="gd">-#include <validation.h></span>
#include <httpserver.h>
<span class="gi">+#include <init.h></span>
<span class="gi">+#include <merkleblock.h></span>
#include <net.h>
#include <netbase.h>
#include <rpc/blockchain.h>
#include <rpc/server.h>
#include <rpc/util.h>
<span class="gi">+#include <sidechain.h></span>
<span class="gi">+#include <sidechaindb.h></span>
#include <timedata.h>
#include <util.h>
<span class="gi">+#include <utilmoneystr.h></span>
#include <utilstrencodings.h>
<span class="gi">+#include <validation.h></span>
#ifdef ENABLE_WALLET
<span class="gi">+#include <wallet/coincontrol.h></span>
#include <wallet/rpcwallet.h>
#include <wallet/wallet.h>
#include <wallet/walletdb.h>
<span class="gu">@@ -600,6 +606,514 @@ UniValue logging(const JSONRPCRequest& request)</span>
return result;
}
<span class="gi">+UniValue createcriticaldatatx(const JSONRPCRequest& request)</span>
<span class="gi">+{</span>
<span class="gi">+ // TODO finish</span>
<span class="gi">+ //</span>
<span class="gi">+ if (request.fHelp || request.params.size() != 4)</span>
<span class="gi">+ throw std::runtime_error(</span>
<span class="gi">+ "createcriticaldatatx\n"</span>
<span class="gi">+ "Create a critical data transaction\n"</span>
<span class="gi">+ "\nArguments:\n"</span>
<span class="gi">+ "1. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to be spent.\n"</span>
<span class="gi">+ "2. \"height\" (numeric, required) The block height this transaction must be included in.\n"</span>
<span class="gi">+ "3. \"criticalhash\" (string, required) h* you want added to a coinbase\n"</span>
<span class="gi">+ "\nExamples:\n"</span>
<span class="gi">+ + HelpExampleCli("createcriticaldatatx", "\"amount\", \"height\", \"criticalhash\"")</span>
<span class="gi">+ + HelpExampleRpc("createcriticaldatatx", "\"amount\", \"height\", \"criticalhash\"")</span>
<span class="gi">+ );</span>
<span class="gi">+</span>
<span class="gi">+ // Amount</span>
<span class="gi">+ CAmount nAmount = AmountFromValue(request.params[0]);</span>
<span class="gi">+ if (nAmount <= 0)</span>
<span class="gi">+ throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");</span>
<span class="gi">+</span>
<span class="gi">+ int nHeight = request.params[1].get_int();</span>
<span class="gi">+</span>
<span class="gi">+ // Critical hash</span>
<span class="gi">+ uint256 hashCritical = uint256S(request.params[2].get_str());</span>
<span class="gi">+ if (hashCritical.IsNull())</span>
<span class="gi">+ throw JSONRPCError(RPC_TYPE_ERROR, "Invalid h*");</span>
<span class="gi">+</span>
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ // Create and send the transaction</span>
<span class="gi">+ std::string strError;</span>
<span class="gi">+ if (vpwallets.empty()){</span>
<span class="gi">+ strError = "Error: no wallets are available";</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, strError);</span>
<span class="gi">+ }</span>
<span class="gi">+ std::vector<CRecipient> vecSend;</span>
<span class="gi">+ CRecipient recipient = {CScript() << OP_0, nAmount, false};</span>
<span class="gi">+ vecSend.push_back(recipient);</span>
<span class="gi">+</span>
<span class="gi">+ LOCK2(cs_main, vpwallets[0]->cs_wallet);</span>
<span class="gi">+</span>
<span class="gi">+ CWalletTx wtx;</span>
<span class="gi">+ CReserveKey reservekey(vpwallets[0]);</span>
<span class="gi">+ CAmount nFeeRequired;</span>
<span class="gi">+ int nChangePosRet = -1;</span>
<span class="gi">+ //TODO: set this as a real thing</span>
<span class="gi">+ CCoinControl cc;</span>
<span class="gi">+ if (!vpwallets[0]->CreateTransaction(vecSend, wtx, reservekey, nFeeRequired, nChangePosRet, strError, cc)) {</span>
<span class="gi">+ if (nAmount + nFeeRequired > vpwallets[0]->GetBalance())</span>
<span class="gi">+ strError = strprintf("Error: This transaction requires a transaction fee of at least %s", FormatMoney(nFeeRequired));</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, strError);</span>
<span class="gi">+ }</span>
<span class="gi">+ CValidationState state;</span>
<span class="gi">+ if (!vpwallets[0]->CommitTransaction(wtx, reservekey, g_connman.get(), state)) {</span>
<span class="gi">+ strError = strprintf("Error: The transaction was rejected! Reason given: %s", state.GetRejectReason());</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, strError);</span>
<span class="gi">+ }</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
<span class="gi">+ UniValue ret(UniValue::VOBJ);</span>
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ ret.push_back(Pair("txid", wtx.GetHash().GetHex()));</span>
<span class="gi">+ ret.push_back(Pair("nChangePos", nChangePosRet));</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
<span class="gi">+ return ret;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
<span class="gi">+UniValue createbmmcriticaldatatx(const JSONRPCRequest& request)</span>
<span class="gi">+{</span>
<span class="gi">+ // TODO handle optional height better</span>
<span class="gi">+ if (request.fHelp || request.params.size() != 5)</span>
<span class="gi">+ throw std::runtime_error(</span>
<span class="gi">+ "createbmmcriticaldatatx\n"</span>
<span class="gi">+ "Create a BMM request critical data transaction\n"</span>
<span class="gi">+ "\nArguments:\n"</span>
<span class="gi">+ "1. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to be spent.\n"</span>
<span class="gi">+ "2. \"height\" (numeric, required) The block height this transaction must be included in.\n"</span>
<span class="gi">+ "Note: If 0 is passed in for height, current block height will be used"</span>
<span class="gi">+ "3. \"criticalhash\" (string, required) h* you want added to a coinbase\n"</span>
<span class="gi">+ "4. \"nsidechain\" (numeric, required) Sidechain requesting BMM\n"</span>
<span class="gi">+ "5. \"ndag\" (numeric, required) DAG number\n"</span>
<span class="gi">+ "\nExamples:\n"</span>
<span class="gi">+ + HelpExampleCli("createbmmcriticaldatatx", "\"amount\", \"height\", \"criticalhash\", \"nsidechain\", \"ndag\"")</span>
<span class="gi">+ + HelpExampleRpc("createbmmcriticaldatatx", "\"amount\", \"height\", \"criticalhash\", \"nsidechain\", \"ndag\"")</span>
<span class="gi">+ );</span>
<span class="gi">+</span>
<span class="gi">+ // Amount</span>
<span class="gi">+ CAmount nAmount = AmountFromValue(request.params[0]);</span>
<span class="gi">+ if (nAmount <= 0)</span>
<span class="gi">+ throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");</span>
<span class="gi">+</span>
<span class="gi">+ // Height</span>
<span class="gi">+ int nHeight = request.params[1].get_int();</span>
<span class="gi">+ if (nHeight == 0) {</span>
<span class="gi">+ LOCK(cs_main);</span>
<span class="gi">+ nHeight = chainActive.Height();</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ // Critical hash</span>
<span class="gi">+ uint256 hashCritical = uint256S(request.params[2].get_str());</span>
<span class="gi">+ if (hashCritical.IsNull())</span>
<span class="gi">+ throw JSONRPCError(RPC_TYPE_ERROR, "Invalid h*");</span>
<span class="gi">+</span>
<span class="gi">+ // nSidechain</span>
<span class="gi">+ int nSidechain = request.params[3].get_int();</span>
<span class="gi">+</span>
<span class="gi">+ if (!IsSidechainNumberValid(nSidechain))</span>
<span class="gi">+ throw JSONRPCError(RPC_TYPE_ERROR, "Invalid Sidechain number");</span>
<span class="gi">+</span>
<span class="gi">+ // nDAG</span>
<span class="gi">+ int nDAG = request.params[4].get_int();</span>
<span class="gi">+</span>
<span class="gi">+ // Create critical data</span>
<span class="gi">+ CScript bytes;</span>
<span class="gi">+ bytes.resize(3);</span>
<span class="gi">+ bytes[0] = 0x00;</span>
<span class="gi">+ bytes[1] = 0xbf;</span>
<span class="gi">+ bytes[2] = 0x00;</span>
<span class="gi">+</span>
<span class="gi">+ bytes << CScriptNum::serialize(nSidechain);</span>
<span class="gi">+ bytes << CScriptNum::serialize(nDAG);</span>
<span class="gi">+</span>
<span class="gi">+ CCriticalData criticalData;</span>
<span class="gi">+ criticalData.bytes = std::vector<unsigned char>(bytes.begin(), bytes.end());</span>
<span class="gi">+ criticalData.hashCritical = hashCritical;</span>
<span class="gi">+</span>
<span class="gi">+ // Create transaction with critical data</span>
<span class="gi">+ CMutableTransaction mtx;</span>
<span class="gi">+ mtx.nVersion = 1;</span>
<span class="gi">+ mtx.vout.resize(1);</span>
<span class="gi">+ mtx.vout[0].scriptPubKey = CScript() << OP_TRUE;</span>
<span class="gi">+ mtx.vout[0].nValue = nAmount;</span>
<span class="gi">+</span>
<span class="gi">+ // Set lock time</span>
<span class="gi">+ mtx.nLockTime = nHeight;</span>
<span class="gi">+</span>
<span class="gi">+ // Add critical data</span>
<span class="gi">+ mtx.criticalData = criticalData;</span>
<span class="gi">+</span>
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ // Create and send the transaction</span>
<span class="gi">+ std::string strError;</span>
<span class="gi">+ if (vpwallets.empty()){</span>
<span class="gi">+ strError = "Error: no wallets are available";</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, strError);</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ CCoinControl coinControl;</span>
<span class="gi">+ int nChange = -1;</span>
<span class="gi">+ CAmount nFeeOut;</span>
<span class="gi">+ std::string strFail;</span>
<span class="gi">+ std::set<int> setSubtractFeeFromOutputs;</span>
<span class="gi">+ setSubtractFeeFromOutputs.insert(0);</span>
<span class="gi">+ if (!vpwallets[0]->FundTransaction(mtx, nFeeOut, nChange, strFail, false, setSubtractFeeFromOutputs, coinControl)) {</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, strFail);</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ if (!vpwallets[0]->SignTransaction(mtx)) {</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, "Failed to sign transaction!");</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ CWalletTx wtx;</span>
<span class="gi">+ wtx.fTimeReceivedIsTxTime = true;</span>
<span class="gi">+ wtx.fFromMe = true;</span>
<span class="gi">+ wtx.BindWallet(vpwallets[0]);</span>
<span class="gi">+</span>
<span class="gi">+ wtx.SetTx(MakeTransactionRef(std::move(mtx)));</span>
<span class="gi">+</span>
<span class="gi">+ CReserveKey reserveKey(vpwallets[0]);</span>
<span class="gi">+ CValidationState state;</span>
<span class="gi">+ if (!vpwallets[0]->CommitTransaction(wtx, reserveKey, g_connman.get(), state)) {</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, state.GetRejectReason());</span>
<span class="gi">+ }</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
<span class="gi">+ UniValue ret(UniValue::VOBJ);</span>
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ UniValue obj(UniValue::VOBJ);</span>
<span class="gi">+ obj.push_back(Pair("txid", wtx.GetHash().ToString()));</span>
<span class="gi">+ ret.push_back(Pair("txid", obj));</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
<span class="gi">+ return ret;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
<span class="gi">+// TODO rename or change return value</span>
<span class="gi">+UniValue listsidechaindeposits(const JSONRPCRequest& request)</span>
<span class="gi">+{</span>
<span class="gi">+ if (request.fHelp || request.params.size() != 1)</span>
<span class="gi">+ throw std::runtime_error(</span>
<span class="gi">+ "listsidechaindeposits\n"</span>
<span class="gi">+ "Called by sidechain, return list of deposits\n"</span>
<span class="gi">+ "\nArguments:\n"</span>
<span class="gi">+ "1. \"nsidechain\" (numeric, required) The sidechain number\n"</span>
<span class="gi">+ "\nExamples:\n"</span>
<span class="gi">+ + HelpExampleCli("listsidechaindeposits", "\"nsidechain\"")</span>
<span class="gi">+ + HelpExampleRpc("listsidechaindeposits", "\"nsidechain\"")</span>
<span class="gi">+ );</span>
<span class="gi">+</span>
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ // Check for active wallet</span>
<span class="gi">+ std::string strError;</span>
<span class="gi">+ if (vpwallets.empty()) {</span>
<span class="gi">+ strError = "Error: no wallets are available";</span>
<span class="gi">+ throw JSONRPCError(RPC_WALLET_ERROR, strError);</span>
<span class="gi">+ }</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
<span class="gi">+ // Is nSidechain valid?</span>
<span class="gi">+ uint8_t nSidechain = std::stoi(request.params[0].getValStr());</span>
<span class="gi">+ if (!IsSidechainNumberValid(nSidechain))</span>
<span class="gi">+ throw std::runtime_error("Invalid sidechain number");</span>
<span class="gi">+</span>
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ // Get latest deposit from sidechain DB deposit cache</span>
<span class="gi">+ std::vector<SidechainDeposit> vDeposit = scdb.GetDeposits(nSidechain);</span>
<span class="gi">+ if (!vDeposit.size())</span>
<span class="gi">+ throw std::runtime_error("No deposits in cache");</span>
<span class="gi">+ const SidechainDeposit& deposit = vDeposit.back();</span>
<span class="gi">+</span>
<span class="gi">+ // Add deposit txid to set</span>
<span class="gi">+ uint256 txid = deposit.tx.GetHash();</span>
<span class="gi">+ std::set<uint256> setTxids;</span>
<span class="gi">+ setTxids.insert(txid);</span>
<span class="gi">+</span>
<span class="gi">+ LOCK(cs_main);</span>
<span class="gi">+</span>
<span class="gi">+ // Get deposit output</span>
<span class="gi">+ CBlockIndex* pblockindex = NULL;</span>
<span class="gi">+ Coin coin;</span>
<span class="gi">+ COutPoint c(txid, deposit.n);</span>
<span class="gi">+ if (pcoinsTip->GetCoin(c, coin) && coin.nHeight > 0 && coin.nHeight <= chainActive.Height())</span>
<span class="gi">+ pblockindex = chainActive[coin.nHeight];</span>
<span class="gi">+</span>
<span class="gi">+ if (pblockindex == NULL)</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't get coins");</span>
<span class="gi">+</span>
<span class="gi">+ // Read block containing deposit output</span>
<span class="gi">+ CBlock block;</span>
<span class="gi">+ if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");</span>
<span class="gi">+</span>
<span class="gi">+ // Look for deposit transaction</span>
<span class="gi">+ bool found = false;</span>
<span class="gi">+ for (const auto& tx : block.vtx)</span>
<span class="gi">+ if (tx->GetHash() == txid)</span>
<span class="gi">+ found = true;</span>
<span class="gi">+ if (!found)</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "transaction not found in specified block");</span>
<span class="gi">+</span>
<span class="gi">+ // Serialize and take hex of txout proof</span>
<span class="gi">+ CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);</span>
<span class="gi">+ CMerkleBlock mb(block, setTxids);</span>
<span class="gi">+ ssMB << mb;</span>
<span class="gi">+ std::string strProofHex = HexStr(ssMB.begin(), ssMB.end());</span>
<span class="gi">+</span>
<span class="gi">+ // Calculate user payout</span>
<span class="gi">+ CAmount amtSidechainUTXO = CAmount(0);</span>
<span class="gi">+ CAmount amtUserInput = CAmount(0);</span>
<span class="gi">+ CAmount amtReturning = CAmount(0);</span>
<span class="gi">+ CAmount amtWithdrawn = CAmount(0);</span>
<span class="gi">+ GetSidechainValues(deposit.tx, amtSidechainUTXO, amtUserInput, amtReturning, amtWithdrawn);</span>
<span class="gi">+</span>
<span class="gi">+ std::vector<COutput> vSidechainCoins;</span>
<span class="gi">+ vpwallets[0]->AvailableSidechainCoins(vSidechainCoins, nSidechain);</span>
<span class="gi">+</span>
<span class="gi">+ amtSidechainUTXO = 0;</span>
<span class="gi">+ for (const COutput& output : vSidechainCoins)</span>
<span class="gi">+ amtSidechainUTXO += output.tx->tx->vout[output.i].nValue;</span>
<span class="gi">+ CAmount amtUserPayout = amtReturning;</span>
<span class="gi">+</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
<span class="gi">+ UniValue ret(UniValue::VOBJ);</span>
<span class="gi">+</span>
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ UniValue obj(UniValue::VOBJ);</span>
<span class="gi">+ obj.push_back(Pair("nsidechain", deposit.nSidechain));</span>
<span class="gi">+ obj.push_back(Pair("keyid", deposit.keyID.ToString()));</span>
<span class="gi">+ obj.push_back(Pair("amountuserpayout", ValueFromAmount(amtUserPayout)));</span>
<span class="gi">+ obj.push_back(Pair("txhex", EncodeHexTx(deposit.tx)));</span>
<span class="gi">+ obj.push_back(Pair("proofhex", strProofHex));</span>
<span class="gi">+</span>
<span class="gi">+ ret.push_back(Pair("deposit", obj));</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
<span class="gi">+ return ret;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
<span class="gi">+UniValue receivewtprime(const JSONRPCRequest& request)</span>
<span class="gi">+{</span>
<span class="gi">+ if (request.fHelp || request.params.size() != 2)</span>
<span class="gi">+ throw std::runtime_error(</span>
<span class="gi">+ "receivewtprime\n"</span>
<span class="gi">+ "Called by sidechain to announce new WT^ for verification\n"</span>
<span class="gi">+ "\nArguments:\n"</span>
<span class="gi">+ "1. \"nsidechain\" (int, required) The sidechain number\n"</span>
<span class="gi">+ "2. \"rawtx\" (string, required) The raw transaction hex\n"</span>
<span class="gi">+ "\nExamples:\n"</span>
<span class="gi">+ + HelpExampleCli("receivewtprime", "")</span>
<span class="gi">+ + HelpExampleRpc("receivewtprime", "")</span>
<span class="gi">+ );</span>
<span class="gi">+</span>
<span class="gi">+ // Is nSidechain valid?</span>
<span class="gi">+ int nSidechain = request.params[0].get_int();</span>
<span class="gi">+ if (!IsSidechainNumberValid(nSidechain))</span>
<span class="gi">+ throw std::runtime_error("Invalid sidechain number!");</span>
<span class="gi">+</span>
<span class="gi">+ // Create CTransaction from hex</span>
<span class="gi">+ CMutableTransaction mtx;</span>
<span class="gi">+ std::string hex = request.params[1].get_str();</span>
<span class="gi">+ if (!DecodeHexTx(mtx, hex))</span>
<span class="gi">+ throw std::runtime_error("Invalid transaction hex!");</span>
<span class="gi">+</span>
<span class="gi">+ CTransaction wtPrime(mtx);</span>
<span class="gi">+</span>
<span class="gi">+ if (wtPrime.IsNull())</span>
<span class="gi">+ throw std::runtime_error("Invalid WT^ hex");</span>
<span class="gi">+</span>
<span class="gi">+ // Add WT^ to sidechain DB and start verification</span>
<span class="gi">+ if (!scdb.AddWTPrime(nSidechain, wtPrime))</span>
<span class="gi">+ throw std::runtime_error("WT^ rejected (duplicate?)");</span>
<span class="gi">+</span>
<span class="gi">+ // Return WT^ hash to verify it has been received</span>
<span class="gi">+ UniValue ret(UniValue::VOBJ);</span>
<span class="gi">+ ret.push_back(Pair("wtxid", wtPrime.GetHash().GetHex()));</span>
<span class="gi">+ return ret;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
<span class="gi">+UniValue receivewtprimeupdate(const JSONRPCRequest& request)</span>
<span class="gi">+{</span>
<span class="gi">+ if (request.fHelp || request.params.size() != 2)</span>
<span class="gi">+ throw std::runtime_error(</span>
<span class="gi">+ "receivewtprimeupdate\n"</span>
<span class="gi">+ "Receive an update for a WT^\n"</span>
<span class="gi">+ "\nArguments:\n"</span>
<span class="gi">+ "1. \"height\" (numeric, required) the block height\n"</span>
<span class="gi">+ "2. \"updates\" (array, required) A json array of json objects\n"</span>
<span class="gi">+ " [\n"</span>
<span class="gi">+ " {\n"</span>
<span class="gi">+ " \"sidechainnumber\":n, (numeric, required) The sidechain number\n"</span>
<span class="gi">+ " \"hashWTPrime\":id, (string, required) The WT^ hash\n"</span>
<span class="gi">+ " \"workscore\":n (numeric, required) The updated workscore\n"</span>
<span class="gi">+ " } \n"</span>
<span class="gi">+ " ,...\n"</span>
<span class="gi">+ " ]\n"</span>
<span class="gi">+ "\nExamples:\n"</span>
<span class="gi">+ + HelpExampleCli("receivewtprimeupdate", "")</span>
<span class="gi">+ + HelpExampleRpc("receivewtprimeupdate", "")</span>
<span class="gi">+ );</span>
<span class="gi">+</span>
<span class="gi">+ RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VARR}, true);</span>
<span class="gi">+ if (request.params[0].isNull() || request.params[1].isNull())</span>
<span class="gi">+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null");</span>
<span class="gi">+</span>
<span class="gi">+ int nHeight = request.params[0].get_int();</span>
<span class="gi">+ SidechainUpdatePackage updatePackage;</span>
<span class="gi">+ updatePackage.nHeight = nHeight;</span>
<span class="gi">+</span>
<span class="gi">+ UniValue inputs = request.params[1].get_array();</span>
<span class="gi">+ for (unsigned int idx = 0; idx < inputs.size(); idx++) {</span>
<span class="gi">+ const UniValue& input = inputs[idx];</span>
<span class="gi">+ const UniValue& o = input.get_obj();</span>
<span class="gi">+</span>
<span class="gi">+ // Get sidechain number</span>
<span class="gi">+ const UniValue& sidechainnumber_v = find_value(o, "sidechainnumber");</span>
<span class="gi">+ if (!sidechainnumber_v.isNum())</span>
<span class="gi">+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing sidechain number");</span>
<span class="gi">+ uint8_t nSidechain = sidechainnumber_v.get_int();</span>
<span class="gi">+</span>
<span class="gi">+ // Is nSidechain valid?</span>
<span class="gi">+ if (!IsSidechainNumberValid(nSidechain))</span>
<span class="gi">+ throw std::runtime_error("Invalid sidechain number");</span>
<span class="gi">+</span>
<span class="gi">+ // Get WT^ hash</span>
<span class="gi">+ uint256 hashWTPrime = ParseHashO(o, "hashWTPrime");</span>
<span class="gi">+ if (hashWTPrime.IsNull())</span>
<span class="gi">+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing WT^ hash");</span>
<span class="gi">+</span>
<span class="gi">+ // Get updated work score</span>
<span class="gi">+ const UniValue& workscore_v = find_value(o, "workscore");</span>
<span class="gi">+ if (!workscore_v.isNum())</span>
<span class="gi">+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing updated workscore");</span>
<span class="gi">+ uint16_t nWorkScore = workscore_v.get_int();</span>
<span class="gi">+</span>
<span class="gi">+ // create MSG</span>
<span class="gi">+ SidechainUpdateMSG update;</span>
<span class="gi">+ update.nSidechain = nSidechain;</span>
<span class="gi">+ update.hashWTPrime = hashWTPrime;</span>
<span class="gi">+ update.nWorkScore = nWorkScore;</span>
<span class="gi">+</span>
<span class="gi">+ // add to package</span>
<span class="gi">+ updatePackage.vUpdate.push_back(update);</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ // Add created package to SCDB WT^ update cache</span>
<span class="gi">+ scdb.AddSidechainNetworkUpdatePackage(updatePackage);</span>
<span class="gi">+</span>
<span class="gi">+ return true;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
<span class="gi">+UniValue getbmmproof(const JSONRPCRequest& request)</span>
<span class="gi">+{</span>
<span class="gi">+ if (request.fHelp || request.params.size() != 2)</span>
<span class="gi">+ throw std::runtime_error(</span>
<span class="gi">+ "getbmmproof\n"</span>
<span class="gi">+ "Called by sidechain\n"</span>
<span class="gi">+ "\nArguments:\n"</span>
<span class="gi">+ "1. \"blockhash\" (string, required) mainchain blockhash with h*\n"</span>
<span class="gi">+ "2. \"criticalhash\" (string, required) h* to create proof of\n"</span>
<span class="gi">+ "\nExamples:\n"</span>
<span class="gi">+ + HelpExampleCli("getbmmproof", "\"blockhash\", \"criticalhash\"")</span>
<span class="gi">+ + HelpExampleRpc("getbmmproof", "\"blockhash\", \"criticalhash\"")</span>
<span class="gi">+ );</span>
<span class="gi">+</span>
<span class="gi">+ uint256 hashBlock = uint256S(request.params[0].get_str());</span>
<span class="gi">+ uint256 hashCritical = uint256S(request.params[1].get_str());</span>
<span class="gi">+</span>
<span class="gi">+ if (!mapBlockIndex.count(hashBlock))</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not found");</span>
<span class="gi">+</span>
<span class="gi">+ CBlockIndex* pblockindex = mapBlockIndex[hashBlock];</span>
<span class="gi">+ if (pblockindex == NULL)</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "pblockindex null");</span>
<span class="gi">+</span>
<span class="gi">+ CBlock block;</span>
<span class="gi">+ if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Failed to read block from disk");</span>
<span class="gi">+</span>
<span class="gi">+ if (!block.vtx.size())</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "No txns in block");</span>
<span class="gi">+</span>
<span class="gi">+ bool fCriticalHashFound = false;</span>
<span class="gi">+ const CTransaction &txCoinbase = *(block.vtx[0]);</span>
<span class="gi">+ for (const CTxOut& out : txCoinbase.vout) {</span>
<span class="gi">+ const CScript& scriptPubKey = out.scriptPubKey;</span>
<span class="gi">+</span>
<span class="gi">+ if (scriptPubKey.size() < sizeof(uint256) + 6)</span>
<span class="gi">+ continue;</span>
<span class="gi">+ if (scriptPubKey[0] != OP_RETURN)</span>
<span class="gi">+ continue;</span>
<span class="gi">+</span>
<span class="gi">+ // Get h*</span>
<span class="gi">+ std::vector<unsigned char> vch (scriptPubKey.begin() + 6, scriptPubKey.begin() + 38);</span>
<span class="gi">+</span>
<span class="gi">+ // TODO return the bytes</span>
<span class="gi">+ // Get Bytes</span>
<span class="gi">+ if (scriptPubKey.size() > 38) {</span>
<span class="gi">+ std::vector<unsigned char> vchBytes(scriptPubKey.begin() + 38, scriptPubKey.end());</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ if (hashCritical == uint256(vch))</span>
<span class="gi">+ fCriticalHashFound = true;</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ if (!fCriticalHashFound)</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "H* not found in block");</span>
<span class="gi">+</span>
<span class="gi">+ std::string strProof = "";</span>
<span class="gi">+ if (!GetTxOutProof(txCoinbase.GetHash(), hashBlock, strProof))</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not get txoutproof...");</span>
<span class="gi">+</span>
<span class="gi">+ std::string strCoinbaseHex = EncodeHexTx(txCoinbase);</span>
<span class="gi">+</span>
<span class="gi">+ UniValue ret(UniValue::VOBJ);</span>
<span class="gi">+ UniValue obj(UniValue::VOBJ);</span>
<span class="gi">+ obj.push_back(Pair("proof", strProof));</span>
<span class="gi">+ obj.push_back(Pair("coinbasehex", strCoinbaseHex));</span>
<span class="gi">+ ret.push_back(Pair("proof", obj));</span>
<span class="gi">+</span>
<span class="gi">+ return ret;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
<span class="gi">+UniValue listpreviousblockhashes(const JSONRPCRequest& request)</span>
<span class="gi">+{</span>
<span class="gi">+ if (request.fHelp || request.params.size() != 0)</span>
<span class="gi">+ throw std::runtime_error(</span>
<span class="gi">+ "listpreviousblockhashes\n"</span>
<span class="gi">+ "Called by sidechain\n"</span>
<span class="gi">+ "\nArguments:\n"</span>
<span class="gi">+ "\nExamples:\n"</span>
<span class="gi">+ + HelpExampleCli("listpreviousblockhashes", "")</span>
<span class="gi">+ + HelpExampleRpc("listpreviousblockhashes", "")</span>
<span class="gi">+ );</span>
<span class="gi">+</span>
<span class="gi">+ int nHeight = chainActive.Height();</span>
<span class="gi">+ int nStart = nHeight - 4;</span>
<span class="gi">+ if (!(nHeight > 0) || !(nStart > 0))</span>
<span class="gi">+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Insufficient blocks connected to complete request!");</span>
<span class="gi">+</span>
<span class="gi">+ std::vector<uint256> vHash;</span>
<span class="gi">+ for (int i = nStart; i <= nHeight; i++) {</span>
<span class="gi">+ uint256 hashBlock = chainActive[i]->GetBlockHash();</span>
<span class="gi">+ vHash.push_back(hashBlock);</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ UniValue ret(UniValue::VARR);</span>
<span class="gi">+ for (const uint256& hash : vHash) {</span>
<span class="gi">+ UniValue obj(UniValue::VOBJ);</span>
<span class="gi">+ obj.push_back(Pair("hash", hash.ToString()));</span>
<span class="gi">+ ret.push_back(obj);</span>
<span class="gi">+ }</span>
<span class="gi">+</span>
<span class="gi">+ return ret;</span>
<span class="gi">+}</span>
<span class="gi">+</span>
UniValue echo(const JSONRPCRequest& request)
{
if (request.fHelp)
<span class="gu">@@ -640,6 +1154,15 @@ static const CRPCCommand commands[] =</span>
{ "hidden", "echo", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
{ "hidden", "echojson", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
{ "hidden", "getinfo", &getinfo_deprecated, {}},
<span class="gi">+</span>
<span class="gi">+ /* Used by sidechain (not shown in help) */</span>
<span class="gi">+ { "hidden", "createcriticaldatatx", &createcriticaldatatx, {"amount", "height", "criticalhash"}},</span>
<span class="gi">+ { "hidden", "createbmmcriticaldatatx", &createbmmcriticaldatatx, {"amount", "height", "criticalhash", "nsidechain", "ndag"}},</span>
<span class="gi">+ { "hidden", "listsidechaindeposits", &listsidechaindeposits, {"nsidechain"}},</span>
<span class="gi">+ { "hidden", "receivewtprime", &receivewtprime, {"nsidechain","rawtx"}},</span>
<span class="gi">+ { "hidden", "receivewtprimeupdate", &receivewtprimeupdate, {"height","update"}},</span>
<span class="gi">+ { "hidden", "getbmmproof", &getbmmproof, {"blockhash", "criticalhash"}},</span>
<span class="gi">+ { "hidden", "listpreviousblockhashes", &listpreviousblockhashes, {}},</span>
};
void RegisterMiscRPCCommands(CRPCTable &t)
<span class="gh">diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp</span>
old mode 100644
new mode 100755
<span class="gh">index 4e868b7c1..d1736dc8c</span>
<span class="gd">--- a/src/qt/bitcoingui.cpp</span>
<span class="gi">+++ b/src/qt/bitcoingui.cpp</span>
<span class="gu">@@ -17,6 +17,7 @@</span>
#include <qt/platformstyle.h>
#include <qt/rpcconsole.h>
#include <qt/utilitydialog.h>
<span class="gi">+#include <qt/sidechaintabledialog.h></span>
#ifdef ENABLE_WALLET
#include <qt/walletframe.h>
<span class="gu">@@ -109,6 +110,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *</span>
openRPCConsoleAction(0),
openAction(0),
showHelpMessageAction(0),
<span class="gi">+ showSidechainTableDialogAction(0),</span>
trayIcon(0),
trayIconMenu(0),
notificator(0),
<span class="gu">@@ -158,6 +160,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *</span>
/** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame(_platformStyle, this);
setCentralWidget(walletFrame);
<span class="gi">+</span>
<span class="gi">+ sidechainTableDialog = new SidechainTableDialog(this);</span>
} else
#endif // ENABLE_WALLET
{
<span class="gu">@@ -377,6 +381,9 @@ void BitcoinGUI::createActions()</span>
showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Bitcoin command-line options").arg(tr(PACKAGE_NAME)));
<span class="gi">+ showSidechainTableDialogAction = new QAction(platformStyle->TextColorIcon(":/icons/history"), tr("&Sidechain Tables"), this);</span>
<span class="gi">+ showSidechainTableDialogAction->setStatusTip(tr("Show Sidechain tables"));</span>
<span class="gi">+</span>
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
<span class="gu">@@ -398,6 +405,7 @@ void BitcoinGUI::createActions()</span>
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
<span class="gi">+ connect(showSidechainTableDialogAction, SIGNAL(triggered()), this, SLOT(showSidechainTableDialog()));</span>
}
#endif // ENABLE_WALLET
<span class="gu">@@ -443,6 +451,7 @@ void BitcoinGUI::createMenuBar()</span>
if(walletFrame)
{
help->addAction(openRPCConsoleAction);
<span class="gi">+ help->addAction(showSidechainTableDialogAction);</span>
}
help->addAction(showHelpMessageAction);
help->addSeparator();
<span class="gu">@@ -498,13 +507,13 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)</span>
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());
<span class="gd">- </span>
<span class="gi">+</span>
OptionsModel* optionsModel = _clientModel->getOptionsModel();
if(optionsModel)
{
// be aware of the tray icon disable state change reported by the OptionsModel object.
connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
<span class="gd">- </span>
<span class="gi">+</span>
// initialize the disable state of the tray icon with the current value in the model.
setTrayIconVisible(optionsModel->getHideTrayIcon());
}
<span class="gu">@@ -614,6 +623,7 @@ void BitcoinGUI::createTrayIconMenu()</span>
trayIconMenu->addSeparator();
trayIconMenu->addAction(optionsAction);
trayIconMenu->addAction(openRPCConsoleAction);
<span class="gi">+ trayIconMenu->addAction(showSidechainTableDialogAction);</span>
#ifndef Q_OS_MAC // This is built-in on Mac
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
<span class="gu">@@ -670,6 +680,11 @@ void BitcoinGUI::showHelpMessageClicked()</span>
}
#ifdef ENABLE_WALLET
<span class="gi">+void BitcoinGUI::showSidechainTableDialog()</span>
<span class="gi">+{</span>
<span class="gi">+ sidechainTableDialog->exec();</span>
<span class="gi">+}</span>
<span class="gi">+</span>
void BitcoinGUI::openClicked()
{
OpenURIDialog dlg(this);
<span class="gu">@@ -1046,7 +1061,7 @@ void BitcoinGUI::setHDStatus(int hdEnabled)</span>
labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
<span class="gd">- // eventually disable the QLabel to set its opacity to 50% </span>
<span class="gi">+ // eventually disable the QLabel to set its opacity to 50%</span>
labelWalletHDStatusIcon->setEnabled(hdEnabled);
}
<span class="gh">diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h</span>
old mode 100644
new mode 100755
<span class="gh">index ddb7ecb76..9e8fd6e2a</span>
<span class="gd">--- a/src/qt/bitcoingui.h</span>
<span class="gi">+++ b/src/qt/bitcoingui.h</span>
<span class="gu">@@ -25,6 +25,7 @@ class OptionsModel;</span>
class PlatformStyle;
class RPCConsole;
class SendCoinsRecipient;
<span class="gi">+class SidechainTableDialog;</span>
class UnitDisplayStatusBarControl;
class WalletFrame;
class WalletModel;
<span class="gu">@@ -111,6 +112,7 @@ private:</span>
QAction *openRPCConsoleAction;
QAction *openAction;
QAction *showHelpMessageAction;
<span class="gi">+ QAction *showSidechainTableDialogAction;</span>
QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu;
<span class="gu">@@ -119,6 +121,11 @@ private:</span>
HelpMessageDialog *helpMessageDialog;
ModalOverlay *modalOverlay;
<span class="gi">+#ifdef ENABLE_WALLET</span>
<span class="gi">+ /** Sidechain table dialog (for testing) */</span>
<span class="gi">+ SidechainTableDialog *sidechainTableDialog;</span>
<span class="gi">+#endif</span>
<span class="gi">+</span>
/** Keep track of previous number of blocks, to detect progress */
int prevBlocks;
int spinnerFrame;
<span class="gu">@@ -207,6 +214,9 @@ private Q_SLOTS:</span>
/** Show open dialog */
void openClicked();
<span class="gi">+</span>
<span class="gi">+ /** Show sidechain table dialog */</span>
<span class="gi">+ void showSidechainTableDialog();</span>
#endif // ENABLE_WALLET
/** Show configuration dialog */
void optionsClicked();
<span class="gu">@@ -233,7 +243,7 @@ private Q_SLOTS:</span>
/** Show progress dialog e.g. for verifychain */
void showProgress(const QString &title, int nProgress);
<span class="gd">- </span>
<span class="gi">+</span>
/** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */
void setTrayIconVisible(bool);
<span class="gh">diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui</span>
old mode 100644
new mode 100755
<span class="gh">index 195a5560f..fb937df68</span>
<span class="gd">--- a/src/qt/forms/sendcoinsdialog.ui</span>
<span class="gi">+++ b/src/qt/forms/sendcoinsdialog.ui</span>
<span class="gu">@@ -6,8 +6,8 @@</span>
<rect>
<x>0</x>
<y>0</y>
<span class="gd">- <width>850</width></span>
<span class="gd">- <height>526</height></span>
<span class="gi">+ <width>1051</width></span>
<span class="gi">+ <height>706</height></span>
</rect>
</property>
<property name="windowTitle">
<span class="gu">@@ -587,8 +587,8 @@</span>
<rect>
<x>0</x>
<y>0</y>
<span class="gd">- <width>830</width></span>
<span class="gd">- <height>104</height></span>
<span class="gi">+ <width>1029</width></span>
<span class="gi">+ <height>70</height></span>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
<span class="gu">@@ -761,15 +761,15 @@</span>
</item>
<item>
<widget class="QLabel" name="fallbackFeeWarningLabel">
<span class="gi">+ <property name="font"></span>
<span class="gi">+ <font></span>
<span class="gi">+ <weight>75</weight></span>
<span class="gi">+ <bold>true</bold></span>
<span class="gi">+ </font></span>
<span class="gi">+ </property></span>
<property name="toolTip">
<string>Using the fallbackfee can result in sending a transaction that will take several hours or days (or never) to confirm. Consider choosing your fee manually or wait until you have validated the complete chain.</string>
</property>
<span class="gd">- <property name="font"></span>
<span class="gd">- <font></span>
<span class="gd">- <weight>75</weight></span>
<span class="gd">- <bold>true</bold></span>
<span class="gd">- </font></span>
<span class="gd">- </property></span>
<property name="text">
<string>Warning: Fee estimation is currently not possible.</string>
</property>
<span class="gu">@@ -851,10 +851,23 @@</span>
<string>If the custom fee is set to 1000 satoshis and the transaction is only 250 bytes, then &quot;per kilobyte&quot; only pays 250 satoshis in fee, while &quot;total at least&quot; pays 1000 satoshis. For transactions bigger than a kilobyte both pay by kilobyte.</string>
</property>
<property name="text">
<span class="gd">- <string>per kilobyte</string></span>
<span class="gi">+ <string>per &amp;kilobyte</string></span>
</property>
</widget>
</item>
<span class="gi">+ <item></span>
<span class="gi">+ <widget class="QRadioButton" name="radioCustomAtLeast"></span>
<span class="gi">+ <property name="toolTip"></span>
<span class="gi">+ <string>If the custom fee is set to 1000 satoshis and the transaction is only 250 bytes, then &quot;per kilobyte&quot; only pays 250 satoshis in fee, while &quot;total at least&quot; pays 1000 satoshis. For transactions bigger than a kilobyte both pay by kilobyte.</string></span>
<span class="gi">+ </property></span>
<span class="gi">+ <property name="text"></span>
<span class="gi">+ <string>total at &amp;least</string></span>
<span class="gi">+ </property></span>
<span class="gi">+ <attribute name="buttonGroup"></span>
<span class="gi">+ <string notr="true">groupCustomFee</string></span>
<span class="gi">+ </attribute></span>
<span class="gi">+ </widget></span>
<span class="gi">+ </item></span>
<item>
<widget class="BitcoinAmountField" name="customFee"/>
</item>
<span class="gu">@@ -923,7 +936,7 @@</span>
<item>
<widget class="QRadioButton" name="radioSmartFee">
<property name="text">
<span class="gd">- <string>Recommended:</string></span>
<span class="gi">+ <string>&amp;Recommended:</string></span>
</property>
<property name="checked">
<bool>true</bool>
<span class="gu">@@ -953,7 +966,7 @@</span>
<item>
<widget class="QRadioButton" name="radioCustomFee">
<property name="text">
<span class="gd">- <string>Custom:</string></span>
<span class="gi">+ <string>C&amp;ustom:</string></span>
</property>
<attribute name="buttonGroup">
<string notr="true">groupFee</string>
<span class="gu">@@ -1113,6 +1126,9 @@</span>
<property name="toolTip">
<string>With Replace-By-Fee (BIP-125) you can increase a transaction's fee after it is sent. Without this, a higher fee may be recommended to compensate for increased transaction delay risk.</string>
</property>
<span class="gi">+ <property name="text"></span>
<span class="gi">+ <string>Request Replace-By-Fee</string></span>
<span class="gi">+ </property></span>
</widget>
</item>
</layout>
<span class="gu">@@ -1204,6 +1220,47 @@</span>
</property>
</widget>
</item>
<span class="gi">+ <item></span>
<span class="gi">+ <spacer name="horizontalSpacer_8"></span>
<span class="gi">+ <property name="orientation"></span>
<span class="gi">+ <enum>Qt::Horizontal</enum></span>
<span class="gi">+ </property></span>
<span class="gi">+ <property name="sizeType"></span>
<span class="gi">+ <enum>QSizePolicy::Maximum</enum></span>
<span class="gi">+ </property></span>
<span class="gi">+ <property name="sizeHint" stdset="0"></span>
<span class="gi">+ <size></span>
<span class="gi">+ <width>40</width></span>
<span class="gi">+ <height>20</height></span>
<span class="gi">+ </size></span>
<span class="gi">+ </property></span>
<span class="gi">+ </spacer></span>
<span class="gi">+ </item></span>
<span class="gi">+ <item></span>
<span class="gi">+ <widget class="Line" name="line"></span>
<span class="gi">+ <property name="orientation"></span>
<span class="gi">+ <enum>Qt::Vertical</enum></span>
<span class="gi">+ </property></span>
<span class="gi">+ </widget></span>
<span class="gi">+ </item></span>
<span class="gi">+ <item></span>
<span class="gi">+ <widget class="QPushButton" name="sidechainDepositButton"></span>
<span class="gi">+ <property name="text"></span>
<span class="gi">+ <string>Sidechain Deposit</string></span>
<span class="gi">+ </property></span>
<span class="gi">+ <property name="icon"></span>
<span class="gi">+ <iconset resource="../bitcoin.qrc"></span>
<span class="gi">+ <normaloff>:/icons/tx_inout</normaloff>:/icons/tx_inout</iconset></span>
<span class="gi">+ </property></span>
<span class="gi">+ </widget></span>
<span class="gi">+ </item></span>
<span class="gi">+ <item></span>
<span class="gi">+ <widget class="Line" name="line_2"></span>
<span class="gi">+ <property name="orientation"></span>
<span class="gi">+ <enum>Qt::Vertical</enum></span>
<span class="gi">+ </property></span>
<span class="gi">+ </widget></span>
<span class="gi">+ </item></span>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<span class="gu">@@ -1278,6 +1335,7 @@</span>
</resources>
<connections/>
<buttongroups>
<span class="gi">+ <buttongroup name="groupCustomFee"/></span>
<buttongroup name="groupFee"/>
</buttongroups>
</ui>
<span class="gh">diff --git a/src/qt/forms/sidechaindepositdialog.ui b/src/qt/forms/sidechaindepositdialog.ui</span>
new file mode 100755
<span class="gh">index 000000000..11a15e9b5</span>
<span class="gd">--- /dev/null</span>
<span class="gi">+++ b/src/qt/forms/sidechaindepositdialog.ui</span>
<span class="gu">@@ -0,0 +1,142 @@</span>
<span class="gi">+<?xml version="1.0" encoding="UTF-8"?></span>
<span class="gi">+<ui version="4.0"></span>
<span class="gi">+ <class>SidechainDepositDialog</class></span>
<span class="gi">+ <widget class="QDialog" name="SidechainDepositDialog"></span>
<span class="gi">+ <property name="geometry"></span>
<span class="gi">+ <rect></span>
<span class="gi">+ <x>0</x></span>
<span class="gi">+ <y>0</y></span>
<span class="gi">+ <width>594</width></span>