From 4a212c2ccd1dd1dba8dd038f4a77e78ba484ce3e Mon Sep 17 00:00:00 2001 From: Alexey Karyabkin Date: Wed, 18 Apr 2018 17:49:04 +0400 Subject: [PATCH] added function build orphan block - develop --- .idea/deployment.xml | 14 ++++++++++++++ .idea/inspectionProfiles/Project_Default.xml | 14 ++++++++++++++ .idea/webServers.xml | 15 +++++++++++++++ pybtc/blockchain.py | 12 ++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 .idea/deployment.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/webServers.xml diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..5a3288f --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..1f7c45d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/.idea/webServers.xml b/.idea/webServers.xml new file mode 100644 index 0000000..cafab32 --- /dev/null +++ b/.idea/webServers.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/pybtc/blockchain.py b/pybtc/blockchain.py index 3d59474..f4704e1 100644 --- a/pybtc/blockchain.py +++ b/pybtc/blockchain.py @@ -912,3 +912,15 @@ class BlockTemplate(): block += t["data"] return double_sha256(header,1), block + def build_orphan(self, hash, ntime): + self.previous_block_hash = hexlify(reverse_hash(s2rh(hash))).decode() + self.time = hexlify(ntime.to_bytes(4, "big")).decode() + self.height += 1 + self.transactions = list() + self.txid_list = list() + self.scan_tx_list() + self.coinbase_tx = self.create_coinbase_transaction() + self.coinb1, self.coinb2 = self.split_coinbase() + self.target = bits2target(self.bits) + self.difficulty = target2difficulty(self.target) + self.merkle_branches = [hexlify(i).decode() for i in merkle_branches([self.coinbase_tx.hash, ] + self.txid_list)] \ No newline at end of file