Skip to content

Commit b4dbdb6

Browse files
committed
Merge master
2 parents f5765eb + 84af547 commit b4dbdb6

File tree

6 files changed

+28
-31
lines changed

6 files changed

+28
-31
lines changed

block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from merkle_tree import MerkleTree
66

77
MINING_DIFFICULTY = 2
8-
HASH_GENESIS_BLOCK = "b4358083b2c93824360c5779e1cbe00998d7f09553fd7d18ef8f012b59e82a0f"
8+
HASH_GENESIS_BLOCK = "8f73145e22b5eef54041892ff92f7e1ab02d6c7246e76b81f0092a8adb13118e"
99

1010

1111
class Block(object):

blockchain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def _genesis_block(self):
4141
previous_hash = 0
4242
index = 0
4343
b1 = Block(nonce, txs, index, previous_hash)
44+
b1.timestamp = 1572993676
4445

4546
self.chain.append(b1)
4647

init_datas.py

Lines changed: 15 additions & 12 deletions
Large diffs are not rendered by default.

init_transactions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import hashlib
33
from init_datas import creator_address
44
from init_datas import tx_signatures
5+
from init_datas import time
56

67
#from wallet import Wallet
78
#creator_wallet = Wallet(); creator_address = creator_wallet.address; print(creator_address)
@@ -15,16 +16,19 @@ def getInitialTransactions():
1516
for i in range(4):
1617
tx = Transaction('', creator_address, appleHash)
1718
tx.signature = bytes.fromhex(tx_signatures[i*3])
19+
tx.time = time
1820
#tx.sign(creator_wallet); print("sign#", i*3, tx.signature.hex())
1921
txs.append(tx)
2022

2123
tx = Transaction('', creator_address, ironAxeHash)
2224
tx.signature = bytes.fromhex(tx_signatures[i*3 + 1])
25+
tx.time = time
2326
#tx.sign(creator_wallet); print("sign#", i*3 + 1, tx.signature.hex())
2427
txs.append(tx)
2528

2629
tx = Transaction('', creator_address, ironSwordHash)
2730
tx.signature = bytes.fromhex(tx_signatures[i*3 + 2])
31+
tx.time = time
2832
#tx.sign(creator_wallet); print("sign#", i*3 + 2, tx.signature.hex())
2933
txs.append(tx)
3034

transaction.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from mx_crypto import MxCrypto
1111
import json
1212
import jsonpickle
13+
import time
1314

1415

1516
class Transaction:
@@ -21,25 +22,15 @@ def __init__(self, sender_address, recipient_address, value):
2122

2223
self.value = value
2324
self.signature = None
24-
25-
def to_dict(self):
26-
return OrderedDict({'sender_address': self.sender_address,
27-
'recipient_address': self.recipient_address,
28-
'value': self.value})
29-
30-
def toJSON(self):
31-
# return json.dumps({
32-
# 'sender_address': self.sender_address,
33-
# 'recipient_address': self.recipient_address,
34-
# 'value': self.value
35-
# }, sort_keys=True)
36-
return jsonpickle.encode(self)
25+
self.time = time.time()
3726

3827
@property
3928
def to_sign(self):
4029
return jsonpickle.encode({'sender_address': self.sender_address,
4130
'recipient_address': self.recipient_address,
42-
'value': self.value}).encode()
31+
'value': self.value,
32+
'time': self.time
33+
}).encode()
4334

4435
def sign(self, wallet):
4536
self.signature = wallet.sign_transaction(self.to_sign)

wallet.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ def __init__(self, key_length=4096, regenerate=False, testDatas=False):
2222
try:
2323
public_key, private_key = Wallet._import_keys('./testKeys/')
2424
except FileNotFoundError:
25-
print("ERROR : Keys not found")
26-
#TODO : faire quelque chose avec cette erreur ?
27-
testDatas = False
28-
if testDatas is False:
25+
raise ValueError('Test keys not found, please import it')
26+
else:
2927
try:
3028
public_key, private_key = Wallet._import_keys()
3129
except FileNotFoundError:

0 commit comments

Comments
 (0)