-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdiff.txt
1367 lines (1307 loc) · 59 KB
/
diff.txt
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
diff --git a/app/codes/contracts/AuthorizeContract.py b/app/codes/contracts/AuthorizeContract.py
index 5a5795a..b001581 100644
--- a/app/codes/contracts/AuthorizeContract.py
+++ b/app/codes/contracts/AuthorizeContract.py
@@ -17,6 +17,18 @@ class AuthorizeContract(ContractMaster):
self.template = "AuthorizeContract"
self.version = ""
ContractMaster.__init__(self, self.template, self.version, contractaddress)
+
+ def validate(self, txn_data, repo: FetchRepository):
+ method = txn_data["function"]
+ callparams = txn_data["params"]
+
+ if (method == "createTokens"):
+ recipient_address = callparams['recipient_address']
+
+ wallet = repo.select_Query("wallet_address").add_table_name("wallets").where_clause("wallet_address", recipient_address, 1).execute_query_multiple_result({"wallet_address": recipient_address})
+ if len(wallet) == 0:
+ raise Exception("Receipt wallet does not exist")
+
def validateCustodian(self, transaction, custodian_address, custodian_wallet, transaction_manager):
valid = False
diff --git a/app/codes/contracts/PledgingContract.py b/app/codes/contracts/PledgingContract.py
index f6f43a4..ec7242c 100644
--- a/app/codes/contracts/PledgingContract.py
+++ b/app/codes/contracts/PledgingContract.py
@@ -17,6 +17,23 @@ class PledgingContract(ContractMaster):
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
+ def validate(self, txn_data, repo: FetchRepository):
+ method = txn_data["function"]
+ callparams = txn_data["params"]
+
+ if method in ["pledge_tokens", "unpledge_tokens", "default_tokens"]:
+ lender = callparams["lender"]
+ wallet = repo.select_Query("wallet_address").add_table_name("wallets").where_clause("wallet_address", lender, 1).execute_query_multiple_result({"wallet_address": lender})
+ if len(wallet) == 0:
+ raise Exception("Lender wallet does not exist")
+ if method in ["unpledge_tokens", "default_tokens"]:
+ borrower_wallet = callparams["borrower_wallet"]
+ wallet = repo.select_Query("wallet_address").add_table_name("wallets").where_clause("wallet_address", borrower_wallet, 1).execute_query_multiple_result({"wallet_address": borrower_wallet})
+ if len(wallet) == 0:
+ raise Exception("Borrower wallet does not exist")
+
+
+
def __init__(self, contractaddress=None):
self.template = "PledgingContract"
self.version = ""
diff --git a/app/codes/transactionmanager.py b/app/codes/transactionmanager.py
index d33ec31..1ed0a68 100644
--- a/app/codes/transactionmanager.py
+++ b/app/codes/transactionmanager.py
@@ -20,7 +20,7 @@ from app.Configuration import Configuration
from app.nvalues import CUSTODIAN_DAO_ADDRESS
-from ..ntypes import NEWRL_TOKEN_CODE, NEWRL_TOKEN_MULTIPLIER, TRANSACTION_MINER_ADDITION, TRANSACTION_ONE_WAY_TRANSFER, TRANSACTION_SC_UPDATE, TRANSACTION_SMART_CONTRACT, TRANSACTION_TRUST_SCORE_CHANGE, TRANSACTION_TWO_WAY_TRANSFER, TRANSACTION_WALLET_CREATION, TRANSACTION_TOKEN_CREATION
+from ..ntypes import NEWRL_TOKEN_CODE, NEWRL_TOKEN_MULTIPLIER, NUSD_TOKEN_CODE, TRANSACTION_MINER_ADDITION, TRANSACTION_ONE_WAY_TRANSFER, TRANSACTION_SC_UPDATE, TRANSACTION_SMART_CONTRACT, TRANSACTION_TRUST_SCORE_CHANGE, TRANSACTION_TWO_WAY_TRANSFER, TRANSACTION_WALLET_CREATION, TRANSACTION_TOKEN_CREATION
from ..constants import CUSTODIAN_OWNER_TYPE, MEMPOOL_PATH, NEWRL_DB
from .utils import get_person_id_for_wallet_address, get_time_ms
@@ -226,28 +226,19 @@ class Transactionmanager:
# check if the sender has enough balance to spend
self.validity = 0
+ if not validate_transaction_fee(self.transaction, cur=cur):
+ return False
+
+ fee_token_code = self.transaction['currency']
if 'fee' in self.transaction:
fee = self.transaction['fee']
else:
fee = 0
- if 'is_child_txn' in self.transaction:
- is_child_sc = self.transaction['is_child_txn']
- else:
- is_child_sc = False
-
- if not (self.transaction['type'] in [TRANSACTION_MINER_ADDITION, TRANSACTION_SC_UPDATE] or is_child_sc) :
- currency = self.transaction['currency']
- if currency == NEWRL_TOKEN_CODE:
- if fee < NEWRL_TOKEN_MULTIPLIER:
- return False
- else:
- return False
-
if self.transaction['type'] == TRANSACTION_WALLET_CREATION:
custodian = self.transaction['specific_data']['custodian_wallet']
walletaddress = self.transaction['specific_data']['wallet_address']
- if not is_custodian_wallet(custodian):
+ if not is_custodian_wallet(custodian, cur=cur):
logger.warn('Invalid custodian wallet')
self.validity = 0
else:
@@ -264,7 +255,7 @@ class Transactionmanager:
else:
self.validity = 0 # other custodian cannot sign someone's linked wallet address
else: # this is a new wallet and person
- if is_wallet_valid(walletaddress) and not is_smart_contract(walletaddress, cur=cur):
+ if is_wallet_valid(walletaddress, cur=cur) and not is_smart_contract(walletaddress, cur=cur):
print("Wallet with address",
walletaddress, " already exists.")
self.validity = 0
@@ -278,7 +269,7 @@ class Transactionmanager:
fovalidity = False
custvalidity = False
if firstowner:
- if is_wallet_valid(firstowner):
+ if is_wallet_valid(firstowner, cur=cur):
# print("Valid first owner")
fovalidity = True
else:
@@ -290,7 +281,7 @@ class Transactionmanager:
fovalidity = False # amount cannot be non-zero if no first owner
else:
fovalidity = True
- if is_wallet_valid(custodian):
+ if is_wallet_valid(custodian, cur=cur):
# print("Valid custodian")
custvalidity = True
if not fovalidity:
@@ -426,33 +417,62 @@ class Transactionmanager:
sender2, tokencode2, cur)
- # if token1amt > startingbalance1: # sender1 is trying to send more than she owns
- # print("sender1 is trying to send,", token1amt, "she owns,",
- # startingbalance1, " invalidating transaction")
- # # self.transaction['valid']=0;
- # self.validity = 0
-
- # if ttype == 4:
- # if token2amt + (fee/2)> startingbalance2: # sender2 is trying to send more than she owns
- # print(
- # "sender2 is trying to send more than she owns, invalidating transaction")
- # # self.transaction['valid']=0;
- # self.validity = 0
-
- if ttype == 4:
- # double checking
- if token1amt + math.ceil(fee/2) <= startingbalance1 and token2amt + math.ceil(fee/2) <= startingbalance2:
- print(
- "Valid economics of transaction. Changing economic validity value to 1")
- # self.transaction['valid']=1;
- self.validity = 1
if ttype == 5:
- if token1amt + fee <= startingbalance1:
- print(
- "Valid economics of transaction. Changing economic validity value to 1")
- # self.transaction['valid']=1;
+ #if token being transfered and fee token is same, calculate together
+ if tokencode1 == fee_token_code:
+ if token1amt + fee <= startingbalance1:
+ print(
+ "Valid economics of transaction. Changing economic validity value to 1")
+ self.validity = 1
+ else:
+ #check for fee and token1 balances seperately
+ fee_token_balance = get_wallet_token_balance_tm(
+ sender1, fee_token_code, cur=cur)
+ if fee <= fee_token_balance:
+ if token1amt <= startingbalance1:
+ print(
+ "Valid economics of transaction. Changing economic validity value to 1")
+ self.validity = 1
+ if ttype == 4:
+ token1_balance_validity = False
+ token2_balance_validity = False
+
+ #token1 balance check
+ if tokencode1 == fee_token_code:
+ if token1amt + math.ceil(fee/2) <= startingbalance1:
+ print(
+ "Valid economics of transaction. Changing economic validity value to 1")
+ token1_balance_validity = True
+ else:
+ #check for fee and token1 balances seperately
+ fee_token_balance = get_wallet_token_balance_tm(
+ sender1, fee_token_code, cur=cur)
+ if math.ceil(fee/2) <= fee_token_balance:
+ if token1amt <= startingbalance1:
+ print(
+ "Valid economics of transaction. Changing economic validity value to 1")
+ token1_balance_validity = True
+
+ #token2 balance check
+ if tokencode2 == fee_token_code:
+ if token2amt + math.ceil(fee/2) <= startingbalance2:
+ print(
+ "Valid economics of transaction. Changing economic validity value to 1")
+ token2_balance_validity = True
+ else:
+ #check for fee and token2 balances seperately
+ fee_token_balance = get_wallet_token_balance_tm(
+ sender2, fee_token_code, cur=cur)
+ if math.ceil(fee/2) <= fee_token_balance:
+ if token2amt <= startingbalance2:
+ print(
+ "Valid economics of transaction. Changing economic validity value to 1")
+ token2_balance_validity = True
+
+ if token1_balance_validity and token2_balance_validity:
self.validity = 1
+
if self.transaction['type'] == TRANSACTION_TRUST_SCORE_CHANGE: # score change transaction
ttype = self.transaction['type']
# personid1 = self.transaction['specific_data']['personid1']
@@ -805,3 +825,50 @@ def is_smart_contract(address, cur=None):
def __str__(self):
return str(self.get_transaction_complete())
+
+def validate_transaction_fee(transaction, cur):
+ if cur is None:
+ con = sqlite3.connect(NEWRL_DB)
+ cur = con.cursor()
+ cursor_opened = True
+ else:
+ cursor_opened = False
+
+ fee_tokens = [NEWRL_TOKEN_CODE, NUSD_TOKEN_CODE]
+ fee_token_code = transaction['currency']
+ if not fee_token_code in fee_tokens:
+ logger.info("Provided fee currency is not allowed")
+ return False
+
+ if 'fee' in transaction:
+ fee = transaction['fee']
+ else:
+ fee = 0
+
+ if 'is_child_txn' in transaction:
+ is_child_sc = transaction['is_child_txn']
+ if is_child_sc:
+ return True
+
+ if transaction['type'] in [TRANSACTION_MINER_ADDITION, TRANSACTION_SC_UPDATE]:
+ return True
+
+
+ if fee_token_code == NEWRL_TOKEN_CODE:
+ if fee < NEWRL_TOKEN_MULTIPLIER:
+ logger.info(f"Not enough fee provided: {fee}")
+
+ payees = get_valid_addresses(transaction, cur=cur)
+ for payee in payees:
+ balance = get_wallet_token_balance(cur, payee, fee_token_code)
+ fee_to_charge = math.ceil(fee / len(payees))
+ if balance < fee_to_charge:
+ logger.info(f"Payee does not have enough balance. Required:{fee_to_charge} Available:{balance}")
+ return False
+ else:
+ logger.info(f"Fee payment currency not allowed")
+ return False
+
+ if cursor_opened:
+ con.close()
+ return True
\ No newline at end of file
diff --git a/app/codes/validator.py b/app/codes/validator.py
index 035e5ba..b085e2e 100644
--- a/app/codes/validator.py
+++ b/app/codes/validator.py
@@ -4,6 +4,7 @@ import base64
import datetime
import json
import logging
+import sqlite3
import ecdsa
import os
@@ -15,7 +16,7 @@ from app.codes.p2p.transport import send
from app.ntypes import BLOCK_VOTE_INVALID, BLOCK_VOTE_VALID, TRANSACTION_MINER_ADDITION
from .utils import get_last_block_hash
from .transactionmanager import Transactionmanager
-from ..constants import IS_TEST, MAX_TRANSACTION_SIZE, MEMPOOL_PATH, MEMPOOL_TRANSACTION_LIFETIME_SECONDS
+from ..constants import IS_TEST, MAX_TRANSACTION_SIZE, MEMPOOL_PATH, MEMPOOL_TRANSACTION_LIFETIME_SECONDS, NEWRL_DB
from .p2p.outgoing import propogate_transaction_to_peers
from .chainscanner import get_transaction
@@ -57,7 +58,10 @@ def validate(transaction, propagate=False, validate_economics=True):
msg = "Transaction has invalid signatures"
else:
if validate_economics:
- economics_valid = transaction_manager.econvalidator()
+ con = sqlite3.connect(NEWRL_DB)
+ cur = con.cursor()
+ economics_valid = transaction_manager.econvalidator(cur=cur)
+ con.close()
if not economics_valid:
msg = "Transaction economic validation failed"
valid = False
diff --git a/app/constants.py b/app/constants.py
index 9461b73..b6efd88 100644
--- a/app/constants.py
+++ b/app/constants.py
@@ -27,11 +27,11 @@ elif NEWRL_ENV == 'test':
DATA_PATH = 'data_test/'
print('Using test constants')
elif NEWRL_ENV == 'devnet':
- BOOTSTRAP_NODES = ['devnet.newrl.net']
- NETWORK_TRUSTED_ARCHIVE_NODES = ['devnetarchive1.newrl.net']
- NEWRL_PORT = 8420
- DATA_PATH = 'data_devnet/'
- print('Using devnet constants')
+ BOOTSTRAP_NODES = ['bootstrap1-lakeshore.newrl.net']
+ NETWORK_TRUSTED_ARCHIVE_NODES = ['archive1-lakeshore.newrl.net']
+ NEWRL_PORT = 8424
+ DATA_PATH = 'data_testnet/'
+ print('Using devnet (lakeshore) constants')
else: # default ot devnet
BOOTSTRAP_NODES = ['devnet.newrl.net']
NETWORK_TRUSTED_ARCHIVE_NODES = ['devnetarchive1.newrl.net']
diff --git a/cloudwatch-logs-config b/cloudwatch-logs-config
new file mode 100644
index 0000000..ff5f55c
--- /dev/null
+++ b/cloudwatch-logs-config
@@ -0,0 +1,52 @@
+sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/home/ubuntu/cloudwatch-config.conf
+{
+ "agent": {
+ "metrics_collection_interval": 10,
+ "logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
+ },
+ "metrics": {
+ "namespace": "MainnetArchiveNodeLogs",
+ "force_flush_interval": 30,
+ "metrics_collected": {
+ "cpu": {
+ "resources": [
+ "*"
+ ],
+ "measurement": [
+ {
+ "name": "cpu_usage_idle",
+ "rename": "CPU_USAGE_IDLE",
+ "unit": "Percent"
+ },
+ {
+ "name": "cpu_usage_nice",
+ "unit": "Percent"
+ },
+ "cpu_usage_guest"
+ ],
+ "totalcpu": false,
+ "metrics_collection_interval": 10,
+ "append_dimensions": {
+ "customized_dimension_key_1": "customized_dimension_value_1",
+ "customized_dimension_key_2": "customized_dimension_value_2"
+ }
+ }
+ }
+ },
+ "logs": {
+ "logs_collected": {
+ "files": {
+ "collect_list": [
+ {
+ "file_path": "/home/ubuntu/newrl/logs/newrl-node-log",
+ "log_group_name": "NewrlMainnet",
+ "log_stream_name": "newrl-mainnet-archive",
+ "timezone": "UTC"
+ }
+ ]
+ }
+ },
+ "log_stream_name": "newrl_mainnet_archive",
+ "force_flush_interval": 15
+ }
+ }
\ No newline at end of file
diff --git a/scripts/add_all_network_node_wallets.py b/scripts/add_all_network_node_wallets.py
deleted file mode 100644
index 8ec05f3..0000000
--- a/scripts/add_all_network_node_wallets.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import requests
-
-NODE_URL = 'http://testnet.newrl.net:8182'
-# NODE_URL = 'http://localhost:8182'
-WALLET = {"public": "PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==","private": "zhZpfvpmT3R7mUZa67ui1/G3I9vxRFEBrXNXToVctH0=","address": "0x20513a419d5b11cd510ae518dc04ac1690afbed6"}
-
-# NODE_URL = 'http://testnet.newrl.net:8090'
-# WALLET = {"address": "0xc29193dbab0fe018d878e258c93064f01210ec1a","public": "sB8/+o32Q7tRTjB2XcG65QS94XOj9nP+mI7S6RIHuXzKLRlbpnu95Zw0MxJ2VGacF4TY5rdrIB8VNweKzEqGzg==","private": "xXqOItcwz9JnjCt3WmQpOSnpCYLMcxTKOvBZyj9IDIY="}
-
-
-# NODE_URL = 'http://testnet.newrl.net:8090'
-# WALLET = {
-# "public": "pEeY8E9fdKiZ3nJizmagKXjqDSK8Fz6SAqqwctsIhv8KctDfkJlGnSS2LUj/Igk+LwAl91Y5pUHZTTafCosZiw==",
-# "private": "x1Hp0sJzfTumKDqBwPh3+oj/VhNncx1+DLYmcTKHvV0=",
-# "address": "0x6e206561a7018d84b593c5e4788c71861d716880"
-# }
-
-def add_wallet(public_key):
- add_wallet_request = {
- "custodian_address": WALLET['address'],
- "ownertype": "1",
- "jurisdiction": "910",
- "kyc_docs": [
- {
- "type": 1,
- "hash": "686f72957d4da564e405923d5ce8311b6567cedca434d252888cb566a5b4c401"
- }
- ],
- "specific_data": {},
- "public_key": public_key
- }
-
- response = requests.post(NODE_URL + '/add-wallet', json=add_wallet_request)
-
- unsigned_transaction = response.json()
-
- response = requests.post(NODE_URL + '/sign-transaction', json={
- "wallet_data": WALLET,
- "transaction_data": unsigned_transaction
- })
-
- signed_transaction = response.json()
-
- # print('signed_transaction', signed_transaction)
- print('Sending wallet add transaction to chain')
- response = requests.post(NODE_URL + '/validate-transaction', json=signed_transaction)
- print('Got response from chain\n', response.text)
- assert response.status_code == 200
-
-for public_key in ['PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==', 'FbSwBu4b9aD3JoAaI1IzzWPtEvWiGSn6dIB1cm8h8NZlF4cQrGyESEdVGxS5tebWcalnyFSGjasnEPlyS45SAg==', 'bNSqzHBCK4tnf7rB780eF+Exph0ZCY1Vu2jnBPHq1zw2AIun4aar+vgHmUj8AY4oLF7iWfpBgkkVuHe6L1jepA==', 'KFYSB5fh0dASPz1lSys9DdkMl3Ouukydn6qpo32syTVoYkA5WYhSVCkp9kibr+Lgnw8DkOkAq5CCfP0CopiGHw==', 'Q0sw+ELDy7xWPbi3/1P0KaaYqeLkc97GEsoLumDuAAbAf1i2kNl2pYROY5sFVtmIUAtL4wUP6xoWZhIrcw4LrA==', 'ROSUDqyRFB6ZaHqQFsv5uUfx6GKUNZvpqsFNV/Gvv6Mjw1i+DTpUeFnj7qkKrMwjKZCJVdbRY+5e+Va0i2UGJw==', 'beUpeaiKW4CxBaGSYKCFYEG/f+PvFiS3H3l53OTqFoBpC7Bh1oEJz4QZ0Z1VkIBpXUw8ZcBwdBVLtr04GS/ltg==', 'Z5o1TBi438TSLd/PH1Qv7zIh8Dsx7f/siJXsnQcrEjCI8Pd70FvcMA4nPwQzreusQ6WBhvL1bmgtwx7VEZH5rA==', '4CscAOY/km2vv+5gkr8bVDb+1Po9oCWGHx3PkxBKNzadrDgPpYOJ/IaP65jgi48PQb46njNTbXhbc7ivKnt6lA==', 'KSnHvsppFRdKlQe0YbImp2Ipl3+SO1h7nlGunIB52OlydliOGggcNDtM8ZF0tDk8Fq/NxlhCTZuvVUrGwtRdkw==', 'gBqrxVsPlP/NSZFTHrozyGnp0wucGhJHOlDfefF3Q9WaGqkZWZr5RKPCOjmmKdEs3ohra39LYsGhexXjhZS7lw==', 'PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==']:
- add_wallet(public_key)
diff --git a/scripts/add_token.py b/scripts/add_token.py
index 9ab4b5c..cd571b5 100644
--- a/scripts/add_token.py
+++ b/scripts/add_token.py
@@ -1,16 +1,8 @@
import requests
-# NODE_URL = 'http://testnet.newrl.net:8090'
-# WALLET = {
-# "public": "pEeY8E9fdKiZ3nJizmagKXjqDSK8Fz6SAqqwctsIhv8KctDfkJlGnSS2LUj/Igk+LwAl91Y5pUHZTTafCosZiw==",
-# "private": "x1Hp0sJzfTumKDqBwPh3+oj/VhNncx1+DLYmcTKHvV0=",
-# "address": "0x6e206561a7018d84b593c5e4788c71861d716880"
-# }
-
-# NODE_URL = 'http://localhost:8182'
-NODE_URL = 'http://testnet.newrl.net:8182'
-WALLET = {"public": "PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==","private": "zhZpfvpmT3R7mUZa67ui1/G3I9vxRFEBrXNXToVctH0=","address": "0x20513a419d5b11cd510ae518dc04ac1690afbed6"}
+NODE_URL = 'http://archive1-testnet1.newrl.net:8421'
+WALLET = { "public": "51017a461ecccdc082a49c3f6e17bb9a6259990f6c4d1c1dbb4e067878ddfa71cb4afbe6134bad588395edde20b92c6dd5abab4108d7e6aeb42a06229205cabb", "private": "92a365e63db963a76c0aa1389aee1ae4d25a4539311595820b295d3a77e07618", "address": "0x1342e0ae1664734cbbe522030c7399d6003a07a8" }
token_code = input('Enter token code: ')
amount = input('Issue amount: ')
@@ -37,6 +29,9 @@ response = requests.post(NODE_URL + '/add-token', json=add_wallet_request)
unsigned_transaction = response.json()
+unsigned_transaction['transaction']['trans_code'] = unsigned_transaction['transaction']['trans_code'] + '1'
+unsigned_transaction['transaction']['fee'] = 1000000
+
response = requests.post(NODE_URL + '/sign-transaction', json={
"wallet_data": WALLET,
"transaction_data": unsigned_transaction
diff --git a/scripts/add_token_many.py b/scripts/add_token_many.py
deleted file mode 100644
index 22dff75..0000000
--- a/scripts/add_token_many.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import threading
-import requests
-
-# NODE_URL = 'http://testnet.newrl.net:8090'
-# WALLET = {
-# "public": "pEeY8E9fdKiZ3nJizmagKXjqDSK8Fz6SAqqwctsIhv8KctDfkJlGnSS2LUj/Igk+LwAl91Y5pUHZTTafCosZiw==",
-# "private": "x1Hp0sJzfTumKDqBwPh3+oj/VhNncx1+DLYmcTKHvV0=",
-# "address": "0x6e206561a7018d84b593c5e4788c71861d716880"
-# }
-
-NODE_URL = 'http://testnet.newrl.net:8182'
-WALLET = {"public": "PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==","private": "zhZpfvpmT3R7mUZa67ui1/G3I9vxRFEBrXNXToVctH0=","address": "0x20513a419d5b11cd510ae518dc04ac1690afbed6"}
-
-
-token_code = input('Enter token code: ')
-amount = input('Issue amount: ')
-first_owner = input('First owner[leave blank for custodian]: ')
-
-if first_owner == '':
- first_owner = WALLET['address']
-
-def add_token(tk):
- add_wallet_request = {
- "token_name": 'TPSTKA'+str(tk),
- "token_code": 'TPSTKA'+str(tk),
- "token_type": "1",
- "first_owner": first_owner,
- "custodian": WALLET['address'],
- "legal_doc": "686f72957d4da564e405923d5ce8311b6567cedca434d252888cb566a5b4c401",
- "amount_created": tk,
- "tokendecimal": 0,
- "disallowed_regions": [],
- "is_smart_contract_token": False,
- "token_attributes": {}
- }
-
- response = requests.post(NODE_URL + '/add-token', json=add_wallet_request)
-
- unsigned_transaction = response.json()
-
- response = requests.post(NODE_URL + '/sign-transaction', json={
- "wallet_data": WALLET,
- "transaction_data": unsigned_transaction
- })
-
- signed_transaction = response.json()
-
- print('signed_transaction', signed_transaction)
- response = requests.post(NODE_URL + '/validate-transaction', json=signed_transaction)
- print(response.text)
- print(response.status_code)
- assert response.status_code == 200
-
-for tk in range(1, 10000):
- add_token(tk)
- timer = threading.Timer(1, add_token, (tk,))
- timer.start()
\ No newline at end of file
diff --git a/scripts/add_token_urllib.py b/scripts/add_token_urllib.py
deleted file mode 100644
index 7a5b5c7..0000000
--- a/scripts/add_token_urllib.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import json
-import urllib3
-
-# NODE_URL = 'http://testnet.newrl.net:8182'
-NODE_URL = 'http://testnet.newrl.net:8090'
-# NODE_URL = 'http://newrl.net:8090'
-# WALLET = { "public": "PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==", "private": "zhZpfvpmT3R7mUZa67ui1/G3I9vxRFEBrXNXToVctH0=", "address": "0x20513a419d5b11cd510ae518dc04ac1690afbed6"}
-WALLET = { "address": "0xc29193dbab0fe018d878e258c93064f01210ec1a", "public": "sB8/+o32Q7tRTjB2XcG65QS94XOj9nP+mI7S6RIHuXzKLRlbpnu95Zw0MxJ2VGacF4TY5rdrIB8VNweKzEqGzg==", "private": "xXqOItcwz9JnjCt3WmQpOSnpCYLMcxTKOvBZyj9IDIY=" }
-
-http = urllib3.PoolManager()
-
-token_code = input('Enter token code: ')
-amount = input('Issue amount: ')
-first_owner = input('First owner[c for custodian]: ')
-
-if first_owner == 'c':
- first_owner = WALLET['address']
-
-add_token_request = {
- "token_name": token_code,
- "token_code": token_code,
- "token_type": "1",
- "first_owner": first_owner,
- "custodian": WALLET['address'],
- "legal_doc": "686f72957d4da564e405923d5ce8311b6567cedca434d252888cb566a5b4c401",
- "amount_created": amount,
- "tokendecimal": 0,
- "disallowed_regions": [],
- "is_smart_contract_token": False,
- "token_attributes": {}
-}
-
-response = http.request('POST', NODE_URL + '/add-token', body=json.dumps(add_token_request), headers={'Content-Type': 'application/json'})
-
-unsigned_transaction = json.loads(response.data)
-
-payload = {
- "wallet_data": WALLET,
- "transaction_data": unsigned_transaction
-}
-response = http.request('POST', NODE_URL + '/sign-transaction', body=json.dumps(payload), headers={'Content-Type': 'application/json'})
-
-signed_transaction = json.loads(response.data)
-
-print('signed_transaction', signed_transaction)
-print('Sending wallet add transaction to chain')
-response = http.request('POST', NODE_URL + '/validate-transaction', body=json.dumps(signed_transaction), headers={'Content-Type': 'application/json'})
-print('Got response from chain\n', response.data)
-assert response.status == 200
\ No newline at end of file
diff --git a/scripts/add_transfer.py b/scripts/add_transfer.py
index ab7cae4..abc0e4b 100644
--- a/scripts/add_transfer.py
+++ b/scripts/add_transfer.py
@@ -1,12 +1,8 @@
import json
import requests
-NODE_URL = 'http://testnet.newrl.net:8090'
-WALLET = {
- "public": "pEeY8E9fdKiZ3nJizmagKXjqDSK8Fz6SAqqwctsIhv8KctDfkJlGnSS2LUj/Igk+LwAl91Y5pUHZTTafCosZiw==",
- "private": "x1Hp0sJzfTumKDqBwPh3+oj/VhNncx1+DLYmcTKHvV0=",
- "address": "0x6e206561a7018d84b593c5e4788c71861d716880"
-}
+NODE_URL = 'http://archive1-testnet1.newrl.net:8421'
+WALLET = { "public": "51017a461ecccdc082a49c3f6e17bb9a6259990f6c4d1c1dbb4e067878ddfa71cb4afbe6134bad588395edde20b92c6dd5abab4108d7e6aeb42a06229205cabb", "private": "92a365e63db963a76c0aa1389aee1ae4d25a4539311595820b295d3a77e07618", "address": "0x1342e0ae1664734cbbe522030c7399d6003a07a8" }
transfer_type = input('Enter transfer type[4 for bilateral, 5 for unilateral]: ')
wallet1 = input('Enter first wallet address[leave blank for custodian]: ')
@@ -41,7 +37,7 @@ print(add_transfer_request)
response = requests.post(NODE_URL + '/add-transfer', json=add_transfer_request)
unsigned_transaction = response.json()
-
+unsigned_transaction['transaction']['fee'] = 1000000
response = requests.post(NODE_URL + '/sign-transaction', json={
"wallet_data": WALLET,
"transaction_data": unsigned_transaction
diff --git a/scripts/add_wallet.py b/scripts/add_wallet.py
index e7ae23b..04c82f6 100644
--- a/scripts/add_wallet.py
+++ b/scripts/add_wallet.py
@@ -1,29 +1,20 @@
import requests
-NODE_URL = 'http://testnet.newrl.net:8182'
-WALLET = {"public": "PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==","private": "zhZpfvpmT3R7mUZa67ui1/G3I9vxRFEBrXNXToVctH0=","address": "0x20513a419d5b11cd510ae518dc04ac1690afbed6"}
-# NODE_URL = 'http://testnet.newrl.net:8090'
-# WALLET = {"address": "0xc29193dbab0fe018d878e258c93064f01210ec1a","public": "sB8/+o32Q7tRTjB2XcG65QS94XOj9nP+mI7S6RIHuXzKLRlbpnu95Zw0MxJ2VGacF4TY5rdrIB8VNweKzEqGzg==","private": "xXqOItcwz9JnjCt3WmQpOSnpCYLMcxTKOvBZyj9IDIY="}
+NODE_URL = 'http://archive1-testnet1.newrl.net:8421'
+CUSTODIAN_WALLET = { "public": "51017a461ecccdc082a49c3f6e17bb9a6259990f6c4d1c1dbb4e067878ddfa71cb4afbe6134bad588395edde20b92c6dd5abab4108d7e6aeb42a06229205cabb", "private": "92a365e63db963a76c0aa1389aee1ae4d25a4539311595820b295d3a77e07618", "address": "0x1342e0ae1664734cbbe522030c7399d6003a07a8" }
-# NODE_URL = 'http://testnet.newrl.net:8090'
-# WALLET = {
-# "public": "pEeY8E9fdKiZ3nJizmagKXjqDSK8Fz6SAqqwctsIhv8KctDfkJlGnSS2LUj/Igk+LwAl91Y5pUHZTTafCosZiw==",
-# "private": "x1Hp0sJzfTumKDqBwPh3+oj/VhNncx1+DLYmcTKHvV0=",
-# "address": "0x6e206561a7018d84b593c5e4788c71861d716880"
-# }
-
def add_wallet(public_key):
add_wallet_request = {
- "custodian_address": WALLET['address'],
+ "custodian_address": CUSTODIAN_WALLET['address'],
"ownertype": "1",
"jurisdiction": "910",
"kyc_docs": [
- {
- "type": 1,
- "hash": "686f72957d4da564e405923d5ce8311b6567cedca434d252888cb566a5b4c401"
- }
+ {
+ "type": 1,
+ "hash": ""
+ }
],
"specific_data": {},
"public_key": public_key
@@ -32,9 +23,10 @@ def add_wallet(public_key):
response = requests.post(NODE_URL + '/add-wallet', json=add_wallet_request)
unsigned_transaction = response.json()
+ unsigned_transaction['transaction']['fee'] = 1000000
response = requests.post(NODE_URL + '/sign-transaction', json={
- "wallet_data": WALLET,
+ "wallet_data": CUSTODIAN_WALLET,
"transaction_data": unsigned_transaction
})
@@ -55,6 +47,3 @@ if public_key == '':
public_key = wallet['public']
add_wallet(public_key)
-
-# for public_key in ['PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==', '6YCLRYLmn7xLEZoBnvFVAhqMs0RSLHh6qx4+FMFaMhc2vSDh9pxpdLQdjUSPb/JgFsA25Wpkh5r9myC0HbkaOQ==', 'BZdhXCER0+foqtVOjzfXVi6bE33oS+F7QybRgAKKNG955iIZymjEYZE8RDSKwHI1Ww0iMkaZ6a63ZVR6Q2ZOsw==', 'F4JyBkTigIviJ2ZXBDED38bwi3nKiq8NEyxFlYtmcPB0siRSIBRBpMSzdAU9hdmXodSapJcoO/lhhwlZP413CA==', 'FVatd42BznwblvNFBET9neGXHazylhevWEZX3R0OAKjpaJciUDz0AVHta6BcZrSMcelYrI/wE0HP9tLGbAgwnQ==', 'NLvTGkixKssh3NQB5Jht4pQIiYxJBw/8WYLQ7uwH7EWdO1UlPHSewrIRvPTeEmmrlpa/AmdRvh/6hkbfhZRmYg==', 'K7RISj43N9umd+rP/zarVPmUsH/4MQjukYaZeG81nIt8q2RvJaoTOPNVJRmfMHEvpzMWnD4kil7D4zN84cHloA==', 'qyMa3ncG6xzoOulTfWp1Dbf06yKGo728yqYZctWNCR21NxuCVEoUDCPR99CxEvHBhE7SbUTiLe289jpF52qh7g==', 'hKpfJMvMoOMWvONGJOV9ncQmtupushRNKgYkNLxfnU+1ZnX/XYDZT5ly6oaSypn6fQxtgJFLaHeSSvkZKq0RfA==', 'J8Xy8uUw5AlFGkB9zlLhElVXPstVsbo9V70hqVes6tPJSOspAC+v+2p9HZNESnVQaiXznXkP24rHkz/IoamCmw==', '74ZxEE/N6SUh6PW6erTWkBI4insFRli8XURit0EnTUYU1B36RoQRAFU4egQkJr/WgcJd1SZErqtPpxLn2FzSfA==', 'qcFAa8JxDAubyEjHz2xlkE22GhhPE2HIOxwlna1DfNvtCxPc+D0eK3DHXyvcAuqGgpGhi8baftOkw7He2SqyHw==', 'SG8cb1OTYpbqi230dLn8QN5CLNFnE+ZsjJKhHBGZjHExsnJ3RJ44IhUzU3/+RnGThLd/i4IkRaB0Eic0YSIiXw==', '8nkFblwk1Jq4frQURGvW36/1qHw5MhGv2A1RHnjhtdddAavfLEtO6Dq64MwXqWAy1XN+Wx4wWfztgNv9pdkh4A==', 'pzg0Ms3/R+13KIB/gIrUsISmc5jC/OqhJIJrfy0h4ggodEpiHZsWSRsEF0hZl1HCBOVLUq01jKIZFVZZ9uV8aw==', '+1pc+A8bYWfkiOuPv3XMXzJ3xs2TR6lVwHIfkzJfBYiGxKnNhT2IyRxbjlZshlSgmQEhxB+k7PraaBPdN5d7Wg==', 'JSDoAwJQqmFNVls09fVzcqtAROhh29tLDEXmLqs4ndpCmVdv0kHslX/DhFFq8BFuSv8nfb9uaWfZ9crpFNsDhg==', 'Vhl+eXpXDoc2bgO0IG+wQ+DfOSIQPerEIdXA1N7mDzuUccLHvQEmeho0uk0ormbuwAcHR/nYgK7I3LoCPuNOmA==', 'lrjRgzFVALEP2W52LeflWA2zV5hOxPiKgkJiXSD9IC1PxJShwpQbF8oz0Y6SzowBILH3MXOusiFIl4+EUMsm8Q==', 'Bw6baJzl+Z6yJATcWgd+xVzv2UrfkvMP6STN+TgYevg0gYJGDKjLi4Vr+Gf6Ps3FACcVk26dEjSAuFtHHnodFg==', 'zZuUGV7BMXRVRwo+S1mPWxLuyaSLUCYpEhiTxoX0jR+lNBcC4BSivjkRbeJj6f7/c3iRAy4B9BSTGhI2azMuZA==', '0FKo0JWB+TZa9BN/WoBkK5hqjiDvgnlgF6ONr9m5+ebG9aY1Uz+wVyucbJTdHwyq0xYVjYIoZeL6TEw4lvNYlw==', '3kRKKSz6RxRAYTGdV6s7kMLBSYKuS2+prImkx3g1XBc0xtYQB/VW7cEgVf1DR7Fdn2P1AclESpokmGJK2OENWA==', 'yN4Iuk/sWqwkFn8+wtJuyCHKLWWIIOjwBjua7NFE4AKKIGqXLR2nOvhfkZCZ7DRyGLfAqzphcSYaoH2VNvLpUg==', 'PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==']:
-# add_wallet(public_key)
diff --git a/scripts/add_wallet_urllib.py b/scripts/add_wallet_urllib.py
deleted file mode 100644
index d9a4b95..0000000
--- a/scripts/add_wallet_urllib.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import json
-import urllib3
-
-# NODE_URL = 'http://testnet.newrl.net:8182'
-NODE_URL = 'http://testnet.newrl.net:8090'
-# NODE_URL = 'http://newrl.net:8090'
-# WALLET = {"public": "PizgnsfVWBzJxJ6RteOQ1ZyeOdc9n5KT+GrQpKz7IXLQIiVmSlvZ5EHw83GZL7wqZYQiGrHH+lKU7xE5KxmeKg==","private": "zhZpfvpmT3R7mUZa67ui1/G3I9vxRFEBrXNXToVctH0=","address": "0x20513a419d5b11cd510ae518dc04ac1690afbed6"}
-WALLET = {"address": "0xc29193dbab0fe018d878e258c93064f01210ec1a","public": "sB8/+o32Q7tRTjB2XcG65QS94XOj9nP+mI7S6RIHuXzKLRlbpnu95Zw0MxJ2VGacF4TY5rdrIB8VNweKzEqGzg==","private": "xXqOItcwz9JnjCt3WmQpOSnpCYLMcxTKOvBZyj9IDIY="}
-
-http = urllib3.PoolManager()
-
-public_key = input('Enter public key: ')
-
-if public_key == '0':
- response = http.request('GET', NODE_URL + '/generate-wallet-address')
- wallet = json.loads(response.data)
- print('New wallet\n', wallet, '\n')
- public_key = wallet['public']
-
-
-add_wallet_request = {
- "custodian_address": WALLET['address'],
- "ownertype": "1",
- "jurisdiction": "910",
- "kyc_docs": [
-{
- "type": 1,
- "hash": "686f72957d4da564e405923d5ce8311b6567cedca434d252888cb566a5b4c401"
-}
- ],
- "specific_data": {},
- "public_key": public_key
-}
-
-response = http.request('POST', NODE_URL + '/add-wallet', body=json.dumps(add_wallet_request), headers={'Content-Type': 'application/json'})
-
-unsigned_transaction = json.loads(response.data)
-
-payload = {
- "wallet_data": WALLET,
- "transaction_data": unsigned_transaction
-}
-response = http.request('POST', NODE_URL + '/sign-transaction', body=json.dumps(payload), headers={'Content-Type': 'application/json'})
-
-signed_transaction = json.loads(response.data)
-
-print('signed_transaction', signed_transaction)
-print('Sending wallet add transaction to chain')
-response = http.request('POST', NODE_URL + '/validate-transaction', body=json.dumps(signed_transaction), headers={'Content-Type': 'application/json'})
-print('Got response from chain\n', response.data)
-assert response.status == 200
diff --git a/scripts/analytics_get_token_balance_all_nodes.py b/scripts/analytics_get_token_balance_all_nodes.py
deleted file mode 100644
index 46398aa..0000000
--- a/scripts/analytics_get_token_balance_all_nodes.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import requests
-
-NODE_URL = 'http://18.208.160.119:8182'
-# NODE_URL = 'http://44.203.127.164:8182'
-
-
-def process(node_addr):
- url = 'http://' + node_addr + ':8182/get-token?token_code=TS343'
- response = requests.get(url, timeout=1).json()
- print(node_addr, response['amount_created'])
- # print(f'{node_addr} - Invalid')
- # print(f'{node_addr} - Reverting')
- # requests.post('http://' + node_addr + ':8182/revert-chain',
- # json={
- # "block_index": 0
- # }, timeout=1).json()
- # requests.post('http://' + node_addr + ':8182/sync-chain-from-peers',
- # json={
- # "block_index": 0
- # }, timeout=1).json()
-
-
-for node in ['100.27.31.95', '13.127.196.33', '18.205.152.148', '18.205.189.2', '18.206.94.76', '18.207.216.103', '18.208.182.177', '18.212.66.84', '184.72.208.65', '3.80.209.8', '3.83.50.130', '3.84.50.209', '3.84.77.114', '3.86.220.174', '3.86.95.36', '3.87.215.96', '3.87.239.9', '3.87.59.246', '3.89.74.97', '3.89.88.60', '3.91.148.23', '3.91.240.161', '3.94.187.48', '34.230.43.253', '34.238.254.65', '35.171.16.241', '35.175.149.140', '44.201.104.135', '44.201.195.243', '44.202.100.22', '44.202.112.192', '44.202.36.179', '44.202.6.221', '44.203.125.108', '44.203.155.59', '44.204.232.32', '44.204.33.70', '52.203.35.134', '52.207.247.190', '52.23.232.237', '52.87.240.182', '52.90.193.227', '52.91.186.245', '52.91.72.62', '52.91.72.92', '54.158.53.69', '54.164.113.49', '54.164.15.194', '54.165.186.46', '54.173.64.147', '54.175.45.195', '54.197.74.80', '54.209.119.94', '54.209.184.138', '54.209.95.85', '54.210.130.74', '54.224.29.208', '54.237.250.151', '54.84.93.34', '54.85.121.224', 'testnet.newrl.net']:
- try:
- process(node)
- except:
- pass
- # print(f'{node} - Unreachable')
diff --git a/scripts/kill_server.sh b/scripts/kill_server.sh
index 6d6a614..755d238 100755
--- a/scripts/kill_server.sh
+++ b/scripts/kill_server.sh
@@ -1,2 +1,3 @@
-lsof -P | grep 8090 | awk '{print $2}' | xargs kill -9
-fuser -k 8182/tcp
\ No newline at end of file
+# lsof -P | grep 8090 | awk '{print $2}' | xargs kill -9
+# fuser -k 8182/tcp
+pkill -9 python
\ No newline at end of file
diff --git a/scripts/node_chain_verify.py b/scripts/node_chain_verify.py
deleted file mode 100644
index 9c85b2e..0000000
--- a/scripts/node_chain_verify.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import requests
-
-NODE_URL = 'http://18.208.160.119:8182'
-# NODE_URL = 'http://44.203.127.164:8182'
-
-
-def verify_node(node_address):
- node_address = 'http://' + node_address + ':8182'
- last_block_url = node_address + '/get-last-block-index'
- print(last_block_url)
- last_block = requests.get(node_address + '/get-last-block-index', timeout=1).text
- last_block = int(last_block)
-
- blocks = requests.post(node_address + '/get-blocks', json={
- "block_indexes": list(range(1, last_block + 1))
- }, timeout=10).json()
-
- previous_hash = "0"
-
- for block in blocks:
- print(block['block_index'])
- if block['previous_hash'] != previous_hash:
- print('Chain invalid from index', block['block_index'])
- previous_hash = block['hash']
-
- print(f'{node_address} - chain is valid')
-
-
-def check_block_exist(node_addr):
- url = 'http://' + node_addr + ':8182/get-block?block_index=1'
- block = requests.get(url, timeout=1).json()
- if 'block_index' not in block:
- # print(f'{node_addr} - Invalid')
- print(f'{node_addr} - Reverting')
- requests.post('http://' + node_addr + ':8182/revert-chain?block_index=0&propogate=false', timeout=1).json()
- requests.post('http://' + node_addr + ':8182/sync-chain-from-peers',
- json={
- "block_index": 0
- }, timeout=1).json()
-
-
-for node in ['100.27.31.95', '13.127.196.33', '18.205.152.148', '18.205.189.2', '18.206.94.76', '18.207.216.103', '18.208.182.177', '18.212.66.84', '184.72.208.65', '3.80.209.8', '3.83.50.130', '3.84.50.209', '3.84.77.114', '3.86.220.174', '3.86.95.36', '3.87.215.96', '3.87.239.9', '3.87.59.246', '3.89.74.97', '3.89.88.60', '3.91.148.23', '3.91.240.161', '3.94.187.48', '34.230.43.253', '34.238.254.65', '35.171.16.241', '35.175.149.140', '44.201.104.135', '44.201.195.243', '44.202.100.22', '44.202.112.192', '44.202.36.179', '44.202.6.221', '44.203.125.108', '44.203.155.59', '44.204.232.32', '44.204.33.70', '52.203.35.134', '52.207.247.190', '52.23.232.237', '52.87.240.182', '52.90.193.227', '52.91.186.245', '52.91.72.62', '52.91.72.92', '54.158.53.69', '54.164.113.49', '54.164.15.194', '54.165.186.46', '54.173.64.147', '54.175.45.195', '54.197.74.80', '54.209.119.94', '54.209.184.138', '54.209.95.85', '54.210.130.74', '54.224.29.208', '54.237.250.151', '54.84.93.34', '54.85.121.224', 'testnet.newrl.net']:
- try:
- check_block_exist(node)
- except:
- pass
- # print(f'{node} - Unreachable')
diff --git a/scripts/nodes.http b/scripts/nodes.http
deleted file mode 100644
index ee8a91b..0000000
--- a/scripts/nodes.http
+++ /dev/null
@@ -1,61 +0,0 @@
-
-GET http://testnet.newrl.net:8182/get-last-block-index
-GET http://testnet.newrl.net:8182/get-node-wallet-address
-GET http://testnet.newrl.net:8182/get-miners
-GET http://testnet.newrl.net:8182/get-peers
-GET http://testnet.newrl.net:8182/download-chain
-GET http://testnet.newrl.net:8182/download-state
-POST http://testnet.newrl.net:8182/run-updater
-POST http://testnet.newrl.net:8182/revert-chain?block_index=1&propogate=false
-
-GET http://makemyfund.in:8182/get-last-block-index
-GET http://makemyfund.in:8182/get-node-wallet-address
-GET http://makemyfund.in:8182/get-miners
-GET http://makemyfund.in:8182/get-peers
-POST http://makemyfund.in:8182/run-updater
-POST http://makemyfund.in:8182/revert-chain?block_index=1&propogate=false
-
-GET http://asqisys.com:8182/get-last-block-index
-GET http://asqisys.com:8182/get-node-wallet-address
-GET http://asqisys.com:8182/get-miners
-GET http://asqisys.com:8182/get-peers
-POST http://asqisys.com:8182/run-updater
-GET http://asqisys.com:8182/download-chain
-POST http://asqisys.com:8182/revert-chain?block_index=1&propogate=false
-
-GET http://localhost:8182/get-last-block-index
-GET http://localhost:8182/get-node-wallet-address
-GET http://localhost:8182/get-miners
-GET http://localhost:8182/get-peers
-POST http://localhost:8182/sync-chain-from-peers
-POST http://localhost:8182/run-updater
-GET http://localhost:8182/download-chain
-POST http://localhost:8182/remove-dead-peers
-POST http://localhost:8182/revert-chain?block_index=0&propogate=false
-POST http://localhost:8182/receive-transaction
-
-{"transaction": {"timestamp": 1648185985420, "trans_code": "8d9817b183d61710c82323c082e9652727931ede", "type": 7, "currency": "NWRL", "fee": 0.0, "descr": "Miner addition", "valid": 1, "specific_data": {"wallet_address": "0x76d5ac405f6885c90c407202c474faff93389605", "network_address": "3.6.169.47", "broadcast_timestamp": 1648185985420}}, "signatures": [{"wallet_address": "0x76d5ac405f6885c90c407202c474faff93389605", "msgsign": "peAZ3HOcQDKDS7EVPEmjMqKMkWJcKLKbK3T1wuphelv7vjQvsYHWUEXOu2quk9O7TJKK/kK+yt6/bYbEAW733g=="}]}
-
-GET http://159.223.163.198:8182/get-last-block-index
-GET http://159.223.163.198:8182/get-node-wallet-address
-GET http://159.223.163.198:8182/get-miners
-GET http://159.223.163.198:8182/get-peers
-POST http://159.223.163.198:8182/run-updater
-POST http://159.223.163.198:8182/revert-chain?block_index=10&propogate=false
-POST http://159.223.163.198:8182/run-updater
-
-POST http://testnet.newrl.net:8182/update-software?propogate=true
-POST http://159.223.163.198:8182/update-software?propogate=true
-POST http://asqisys.com:8182/update-software?propogate=true
-POST http://makemyfund.in:8182/update-software?propogate=false
-POST http://localhost:8182/update-software?propogate=true
-
-POST http://159.223.163.198:8182/sync-chain-from-peers
-
-POST http://testnet.newrl.net:8182/revert-chain?block_index=1&propogate=false
-POST http://159.223.163.198:8182/revert-chain?block_index=1&propogate=false
-POST http://asqisys.com:8182/revert-chain?block_index=1&propogate=false
-POST http://makemyfund.in:8182/revert-chain?block_index=1&propogate=false
-POST http://localhost:8182/revert-chain?block_index=2230&propogate=false
-
-POST http://testnet.newrl.net:8182/run-updater?add_to_chain_before_consensus=true
\ No newline at end of file
diff --git a/scripts/restart.sh b/scripts/restart.sh
new file mode 100755
index 0000000..7538a6d
--- /dev/null
+++ b/scripts/restart.sh
@@ -0,0 +1,11 @@
+git pull
+python3 -m venv venv
+source venv/bin/activate
+pip install --upgrade pip
+pip install -r requirements.txt
+export NEWRL_ENV=$1
+python3 -m app.migrations.init
+# python -m app.migrations.migrate_db
+# python3 -m app.codes.auth.make_auth --createnewwallet
+pkill -9 python
+python3 -m app.main $2 $3 $4 $5 $6
\ No newline at end of file
diff --git a/scripts/set_trustscore.py b/scripts/set_trustscore.py
new file mode 100644
index 0000000..77aba1e
--- /dev/null
+++ b/scripts/set_trustscore.py
@@ -0,0 +1,35 @@
+import requests
+
+
+NODE_URL = 'http://archive1-testnet1.newrl.net:8421'
+WALLET = { "wallet_here" }
+
+TRUST_SCORE_DECIMAL = 10000
+
+destination_wallet_address = input('Enter destination wallet address: ')
+source_wallet_address = WALLET['address']
+score = input('Enter score[-100 to 100]: ')
+score = int(score)
+
+trust_score_update_request = {
+ "source_address": source_wallet_address,
+ "destination_address": destination_wallet_address,
+ "tscore": score * TRUST_SCORE_DECIMAL
+ }
+response = requests.post(NODE_URL + '/update-trustscore', json=trust_score_update_request)
+unsigned_transaction = response.json()
+unsigned_transaction['transaction']['fee'] = 1000000
+
+# In production use Newrl sdk to sign offline
+response = requests.post(NODE_URL + '/sign-transaction', json={
+ "wallet_data": WALLET,
+ "transaction_data": unsigned_transaction
+})
+
+signed_transaction = response.json()
+
+print('signed_transaction', signed_transaction)
+response = requests.post(NODE_URL + '/validate-transaction', json=signed_transaction)
+print(response.text)
+print(response.status_code)
+assert response.status_code == 200
diff --git a/scripts/test.sh b/scripts/test.sh
index 69b0a93..3db362e 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -6,7 +6,7 @@
# cp data_test/template/newrl.db data_test/newrl.db
# cp data_test/template/newrl_p2p.db data_test/newrl_p2p.db
# source venv/bin/activate
-export NEWRL_TEST='1' && coverage run -m pytest app/tests/test_transfer.py
+export NEWRL_TEST='Y' && coverage run -m pytest app/tests/test_transfer.py
unset NEWRL_TEST
# rm data_test/mempool/*.json
# rm data_test/tmp/*.json
\ No newline at end of file
diff --git a/scripts/wallet_b64_to_dex.py b/scripts/wallet_b64_to_dex.py
new file mode 100644
index 0000000..384318c
--- /dev/null
+++ b/scripts/wallet_b64_to_dex.py
@@ -0,0 +1,45 @@
+import base64
+import ecdsa
+from Crypto.Hash import keccak
+import hashlib
+import json
+
+
+def get_address_from_public_key(public_key):
+ public_key_bytes = bytes.fromhex(public_key)
+
+ wallet_hash = keccak.new(digest_bits=256)
+ wallet_hash.update(public_key_bytes)
+ keccak_digest = wallet_hash.hexdigest()
+
+ address = '0x' + keccak_digest[-40:]
+ return address
+
+def get_person_id_for_wallet_address(wallet_address):
+ hs = hashlib.blake2b(digest_size=20)
+ hs.update(wallet_address.encode())
+ person_id = 'pi' + hs.hexdigest()
+ return person_id