Skip to content

Commit 0c419fc

Browse files
committed
updated examples' section
1 parent 18ccfbc commit 0c419fc

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

README.rst

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,81 @@ The API documentation can be build with Sphinx but is also available as a PDF fo
99

1010
Complementary to this library is a CC BY-SA 4.0 licensed `Bitcoin programming book <https://github.com/karask/bitcoin-textbook>`_.
1111

12+
1213
Notes
1314
-----
1415
* For schnorr, bech32[m], ripemd160 the python Bitcoin Core reference implementations are used.
1516
* For making calls to a Bitcoin node a simple node proxy object exists, which wraps the python-bitcoinrpc library.
1617
* 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.
1718

19+
1820
Installation
1921
------------
2022
Python version 3 is required. Then just install with:
2123

2224
$ pip install bitcoin-utils
2325

26+
2427
Examples
2528
--------
29+
2630
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+
^^^^^^^^^^^^^^^^^^
2832

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 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.
3135

3236
Segwit Addresses
3337
https://github.com/karask/python-bitcoin-utils/blob/master/examples/keys_segwit_addresses.py - creates P2WPKH, P2SH-P2WPKH, P2WSH and P2SH-P2WSH addresses.
3438

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+
3545
Transaction with P2PKH input and outputs
3646
https://github.com/karask/python-bitcoin-utils/blob/master/examples/p2pkh_transaction.py - creates a simple transaction with one input and two outputs.
3747

3848
Create a P2PKH Transaction with different SIGHASHes
3949
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.
4050

41-
Create a P2SH Address
51+
Create a P2SH Address
4252
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.
4353

4454
Create (spent) a P2SH Transaction
4555
https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2sh_transaction.py - creates a transaction that spends a P2SH output.
4656

57+
Non-standard Transactions
58+
^^^^^^^^^^^^^^^^^^^^^^^^^
59+
4760
Create a non-standard tx
4861
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)
4962

5063
Spend a non-standard tx
5164
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
5265

66+
Segwit Transactions
67+
^^^^^^^^^^^^^^^^^^^
68+
5369
Transaction to pay to a P2WPKH
5470
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)
5571

5672
Spend from a P2SH(P2WPKH) nested segwit address
5773
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
5874

75+
76+
Timelock Transactions
77+
^^^^^^^^^^^^^^^^^^^^^
78+
5979
Create a P2SH address with a relative timelock
6080
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.
6181

6282
Spend from a timelocked address
6383
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.
6484

65-
Use NodeProxy to make calls to a Bitcoin node
66-
https://github.com/karask/python-bitcoin-utils/blob/master/examples/node_proxy.py - make Bitcoin command-line interface calls programmatically (NodeProxy wraps jsonrpc-requests library)
85+
Taproot (segwit v1) Transactions
86+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6787

6888
Spend from a taproot address
6989
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
92112
Spend taproot from script path (has three alternative script path spends - A, B and C)
93113
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.
94114

115+
Other
116+
^^^^^
117+
118+
Use NodeProxy to make calls to a Bitcoin node
119+
https://github.com/karask/python-bitcoin-utils/blob/master/examples/node_proxy.py - make Bitcoin command-line interface calls programmatically (NodeProxy wraps jsonrpc-requests library)
120+
121+
95122
Please explore the codebase or the API documentation (BitcoinUtilities.pdf) for supported functionality and other options.

0 commit comments

Comments
 (0)