[gf4417] Op_return can be set by user.
@@ -29,6 +29,7 @@ def generate_block_with_transactions(num_transactions, amount_per_transaction, o
block_hash = None
for i in range(num_transactions):
+ print(i)
# generate empty blocks to get things going
generate_empty_blocks(101, addr_1)
@@ -54,7 +55,7 @@ def generate_block_with_transactions(num_transactions, amount_per_transaction, o
scriptPubKey = unspent["scriptPubKey"]
redeemScript = unspent["redeemScript"]
amount = str(unspent["amount"])
- change = str(unspent["amount"] - Decimal(0.015))[:6]
+ change = str(unspent["amount"] - Decimal(amount_per_transaction) - Decimal(0.001))[:6]
tx_in = {
"txid": txid,
@@ -65,8 +66,8 @@ def generate_block_with_transactions(num_transactions, amount_per_transaction, o
}
tx_out = {addr_2 : amount_per_transaction}
+ tx_out2 = {"data" : op_return}
tx_out3 = {addr_1 : change}
- tx_out2 = {"data" : 0x1000}
tx_hash = proxy.createrawtransaction([tx_in],[tx_out, tx_out2, tx_out3])
@@ -124,10 +125,12 @@ def export_blocks(blockhashes_with_transactions):
out.append((block, transactions))
+
with open(FILENAME, 'w', encoding='utf-8') as f:
to_dump = []
for i in range(len(out)):
- to_dump.append({"block": out[i][0], "transactions": out[i][1]})
+ #to_dump.append({"block": out[i][0], "transactions": out[i][1]})
+ to_dump.append({"block": out[i][0]})
#f.write(str(to_dump))
#f.write(json.dumps(to_dump, use_decimal=True))
@@ -143,8 +146,8 @@ if __name__ == "__main__":
blockhashes_with_transactions = []
# add blocks
- for i in range(1):
- blockhashes_with_transactions.append(generate_block_with_transactions(1, 0.01, '0x10', address_1, address_2))
+ for i in range(5):
+ blockhashes_with_transactions.append(generate_block_with_transactions(2, 0.01, "1000", address_1, address_2))
generate_empty_blocks(6, address_2)
