-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ2a.py
More file actions
38 lines (33 loc) · 1.37 KB
/
Q2a.py
File metadata and controls
38 lines (33 loc) · 1.37 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
35
36
37
38
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 send_from_P2PKH_transaction
######################################################################
# TODO: Complete the scriptPubKey implementation for Exercise 2
# This script can be redeemed with a signature and the value "secret"
Q2a_txout_scriptPubKey = [
OP_2DUP,
OP_EQUAL,
OP_NOT,
OP_VERIFY,
OP_SHA256,
OP_SWAP,
OP_SHA256,
OP_EQUAL,
]
######################################################################
if __name__ == '__main__':
######################################################################
# 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
######################################################################
response = send_from_P2PKH_transaction(
amount_to_send, txid_to_spend, utxo_index,
Q2a_txout_scriptPubKey, my_private_key, network_type)
print(response.status_code, response.reason)
print(response.text)