-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ2b.py
More file actions
34 lines (29 loc) · 1.32 KB
/
Q2b.py
File metadata and controls
34 lines (29 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from sys import exit
from bitcoin.core.script import *
from lib.utils import *
from lib.config import (my_private_key, my_public_key, my_address,
faucet_address, network_type)
from Q1 import P2PKH_scriptPubKey
from Q2a import Q2a_txout_scriptPubKey
######################################################################
# TODO: set these parameters correctly
amount_to_send = None # amount of BTC in the output you're sending minus fee
txid_to_spend = (
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
utxo_index = None # index of the output you are spending, indices start at 0
######################################################################
txin_scriptPubKey = Q2a_txout_scriptPubKey
######################################################################
# TODO: implement the scriptSig for redeeming the transaction created
# in Exercise 2a.
txin_scriptSig = [
"secret".encode('utf-8'),
"secret".encode('utf-8'),
]
######################################################################
txout_scriptPubKey = P2PKH_scriptPubKey(faucet_address)
response = send_from_custom_transaction(
amount_to_send, txid_to_spend, utxo_index,
txin_scriptPubKey, txin_scriptSig, txout_scriptPubKey, network_type)
print(response.status_code, response.reason)
print(response.text)