Skip to content

Commit bb668c6

Browse files
committed
Changed code structure and renamed the example file
1 parent 6116cb0 commit bb668c6

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@
1111
import hashlib
1212

1313

14-
tx_details = ""
15-
with open(
16-
"./examples/mempool/test_tx.json",
17-
"r",
18-
) as file:
19-
tx_details = json.load(file)
20-
21-
setup("mainnet")
22-
23-
24-
from_addr = "0000000000000000000000000000000000000000000000000000000000000000"
25-
to_addr = "bc1pvh7n6s375348q5zjfrde38nnq2lmhhtyaeqe8hv6t8mf398smeyqnug47s"
26-
to_addr = P2trAddress(to_addr)
27-
28-
2914
def calculate_wtxid(tx_hex):
3015
tx_binary = bytes.fromhex(tx_hex)
3116
hash_once = hashlib.sha256(tx_binary).digest()
@@ -198,6 +183,19 @@ def mine_block(block_header_bytes, target_hex):
198183

199184

200185
def main():
186+
187+
with open(
188+
"./examples/mempool/test_tx.json",
189+
"r",
190+
) as file:
191+
tx_details = json.load(file)
192+
193+
setup("mainnet")
194+
195+
from_txid = "0000000000000000000000000000000000000000000000000000000000000000"
196+
to_addr = "bc1pvh7n6s375348q5zjfrde38nnq2lmhhtyaeqe8hv6t8mf398smeyqnug47s"
197+
to_addr = P2trAddress(to_addr)
198+
201199
# create a coinbase transaction
202200
witness_reserved_value = (
203201
"0000000000000000000000000000000000000000000000000000000000000000"
@@ -209,7 +207,7 @@ def main():
209207
tx1 = Transaction()
210208
tx1 = tx1.from_raw(tx_details["hex"])
211209
txinp = TxInput(
212-
txid=from_addr,
210+
txid=from_txid,
213211
txout_index=0,
214212
script_sig=Script([witness_reserved_value]),
215213
)

0 commit comments

Comments
 (0)