You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+33-6Lines changed: 33 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,61 +9,81 @@ The API documentation can be build with Sphinx but is also available as a PDF fo
9
9
10
10
Complementary to this library is a CC BY-SA 4.0 licensed `Bitcoin programming book <https://github.com/karask/bitcoin-textbook>`_.
11
11
12
+
12
13
Notes
13
14
-----
14
15
* For schnorr, bech32[m], ripemd160 the python Bitcoin Core reference implementations are used.
15
16
* For making calls to a Bitcoin node a simple node proxy object exists, which wraps the python-bitcoinrpc library.
16
17
* For Hierarchical Deterministic keys we wrap the python hdwallet library. For now we wrap only some very basic functionality to acquire a PrivateKey object that is used throughtout the library.
17
18
19
+
18
20
Installation
19
21
------------
20
22
Python version 3 is required. Then just install with:
21
23
22
24
$ pip install bitcoin-utils
23
25
26
+
24
27
Examples
25
28
--------
29
+
26
30
Keys and Addresses
27
-
https://github.com/karask/python-bitcoin-utils/blob/master/examples/keys_addresses.py - creates a private key which we use to derive a public key and in turn an address. We also use the private key to sign a message and then verify it using the public key.
31
+
^^^^^^^^^^^^^^^^^^
28
32
29
-
Hierarchical Deterministic Keys
30
-
https://github.com/karask/python-bitcoin-utils/blob/master/examples/hd_keys.py - creates an extended private key, from an xpriv/tpriv and path, which we use to derive a public key and in turn all different address.
33
+
Legacy Keys and Addresses
34
+
https://github.com/karask/python-bitcoin-utils/blob/master/examples/keys_addresses.py - creates a private keywhich we use to derive a public key and in turn an address. We also use the private key to sign a message and then verify it using the public key.
31
35
32
36
Segwit Addresses
33
37
https://github.com/karask/python-bitcoin-utils/blob/master/examples/keys_segwit_addresses.py - creates P2WPKH, P2SH-P2WPKH, P2WSH and P2SH-P2WSH addresses.
34
38
39
+
Hierarchical Deterministic Keys
40
+
https://github.com/karask/python-bitcoin-utils/blob/master/examples/hd_keys.py - creates an extended private key, from an xpriv/tpriv and path, which we use to derive a public key and in turn all different address (legacy, segwit v0 and taproot (segwit v1).
41
+
42
+
Legacy Transactions (P2PKH, P2SH)
43
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
+
35
45
Transaction with P2PKH input and outputs
36
46
https://github.com/karask/python-bitcoin-utils/blob/master/examples/p2pkh_transaction.py - creates a simple transaction with one input and two outputs.
37
47
38
48
Create a P2PKH Transaction with different SIGHASHes
39
49
https://github.com/karask/python-bitcoin-utils/blob/master/examples/multi_input_sighash_transaction.py - creates a 2-input 2-output transaction with different signature types.
40
50
41
-
Create a P2SH Address
51
+
Create a P2SH Address
42
52
https://github.com/karask/python-bitcoin-utils/blob/master/examples/send_to_p2sh_transaction.py - creates a P2SH address that corresponds to a P2PK redeem script and sends some funds to it.
43
53
44
54
Create (spent) a P2SH Transaction
45
55
https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2sh_transaction.py - creates a transaction that spends a P2SH output.
46
56
57
+
Non-standard Transactions
58
+
^^^^^^^^^^^^^^^^^^^^^^^^^
59
+
47
60
Create a non-standard tx
48
61
https://github.com/karask/python-bitcoin-utils/blob/master/examples/create_non_std_tx.py - sends funds to an address with a non-standard tx (script: OP_ADD OP_5 OP_EQUAL)
49
62
50
63
Spend a non-standard tx
51
64
https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_non_std_tx.py - spends funds from script OP_ADD OP_5 OP_EQUAL
52
65
66
+
Segwit Transactions
67
+
^^^^^^^^^^^^^^^^^^^
68
+
53
69
Transaction to pay to a P2WPKH
54
70
http://github.com/karask/python-bitcoin-utils/blob/master/examples/send_to_p2wpkh_transaction.py - send coins from two P2PKH UTXOs to a native segwit address (P2WPKH)
55
71
56
72
Spend from a P2SH(P2WPKH) nested segwit address
57
73
http://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2sh_p2wpkh_address.py - spend a P2WPKH that is nested into a P2SH for old client compatibility
58
74
75
+
76
+
Timelock Transactions
77
+
^^^^^^^^^^^^^^^^^^^^^
78
+
59
79
Create a P2SH address with a relative timelock
60
80
https://github.com/karask/python-bitcoin-utils/blob/master/examples/create_p2sh_csv_p2pkh_address.py - creates a P2SH address that locks funds (sent to it) with a private key (P2PKH) and a relative locktime of 200 blocks in the future.
61
81
62
82
Spend from a timelocked address
63
83
https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2sh_csv_p2pkh.py - spends from a P2SH(CSV+P2PKH) address as created from above.
https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2tr_default_path.py - single input, single output default key path spending.
@@ -92,4 +112,11 @@ Send to taproot address that contains three scripts path spends
92
112
Spend taproot from script path (has three alternative script path spends - A, B and C)
93
113
https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2tr_three_scripts_by_script_path.py - single input, single output, spend script path B.
0 commit comments