From 2f2b2d26f45263663a2221912dd4db56f73b01b6 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 12 Feb 2018 13:14:54 +0400 Subject: [PATCH] create coinbase transaction --- pybtc/blockchain.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pybtc/blockchain.py b/pybtc/blockchain.py index 91c87b2..aa647fc 100644 --- a/pybtc/blockchain.py +++ b/pybtc/blockchain.py @@ -645,11 +645,15 @@ class Block(): tx.coinbase = True tx.recalculate_txid() if insert: - if self.transactions[0].coinbase: - self.transactions[0] = tx - self.tx_hash_list[0] = tx.hash + if self.transactions: + if self.transactions[0].coinbase: + self.transactions[0] = tx + self.tx_hash_list[0] = tx.hash + else: + self.transactions.insert(0,tx) + self.tx_hash_list.insert(0, tx.hash) else: - self.transactions.insert(0,tx) + self.transactions.insert(0, tx) self.tx_hash_list.insert(0, tx.hash) return tx