Skip to content

Scripts to create different types of outputs, leveraging the bitcoin core test_framework

Notifications You must be signed in to change notification settings

rserranon/bitcoin-output-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Bitcoin-output-Scripts

Scripts to create transactions with different output types and spend them, leveraging the bitcoin core test_framework

The scripts in this repository are created to help people learning Bitcoin, and developers starting in Bitcoin, to understand how transactions, with different types of outputs, are constructed and broadcast to the Bitcoin network.

The repository lives separately from the bitcoin/bitcoin core repository, however a couple of symlinks can be created to be able to leverage your local copy of the functional test_framework. If you already have a directory where you build Bitcoin Core, the symlinks have to be adjusted to point to your local Bitcoin Core repository, in my case they are the following:

  • in this project home directory:
    • ln -s ~/bitcoin-core/bitcoin/test/config.ini config.ini
  • in this project functional directory:
    • ln -s ~/bitcoin-core/bitcoin/test/functional/test_framework test_framework

By doing this, the scripts in the functional folder use the first symlink to share the configuration created by ./configure by bitcoin core. In this way the scripts can look for the test_framework objects directly from your Bitcoin Core directory, by using the second symlink.

Scripts in the funcional repository can be run directly typing the name of the script ./create_P2PK.py. Note the file needs execution permissions (chmod +x <file>).

The options provided by the test_framework can be used, for example ./create_P2PK.py --loglevel=DEBUG --tracerpc.

If you want to know the available options use ./create_P2PK.py -h


The valid standard types of transaction scripts in Tx Outputs are:

Standard transaction types accepted by the Bitcoin network and the miners.

vout scriptPubKey scriptSig redeem
script
witness-stack
P2PK <pubKey>
OP_CHECKSIG
<signature>
P2PKH OP_DUP
OP_HASH160
<pubKeyHash>
OP_EQUALVERIFY
OP_CHECKSIG
<signature>
<publicKey>
P2SH OP_HASH160
scriptHash
OP_EQUAL
data_pushes
<redemScript>
arbitrary
P2WPKH 0
<pubKeyHash>
<signature>
<publicKey>
P2WSH 0
<witnessScriptHash>
<witnessScript>
P2SH-P2WPKH OP_HASH160
<redemScriptHash>
OP_EQUAL
<redemScript> 0
<pubKeyHash>
<signature>
<publicKey>
P2SH-P2WSH OP_HASH160
<redemScriptHash>
<redemScript> 0
<scriptHash>
<witnessScript>
P2TR (key path) 1
<publicKey>
<signature>
P2TR (script path) 1
<publicKey>
[Stack element(s) satisfying tapscript]
<script>
[control_block]

This table was produced by Gloria Zhao1

List and links of implemented scripts:

Legacy

Segwit V0

Segwit V1

Footnotes

  1. Bitcoin Core PR review club on July 7th 2021

About

Scripts to create different types of outputs, leveraging the bitcoin core test_framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages