Coder Social home page Coder Social logo

python-psbt's Introduction

python-psbt

About

This is a python implementation of BIP 174 - Partially Signed Bitcoin Transaction format as defined here: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki

Please reference the above wiki for BIP 174 to understand how it works.

This is only an initial version for proof of concept and study. Please do not deploy for mainnet use without significantly reviewing and testing code for yourself.

That being said, I am very eager for feedback and additional testing to get this to a reliable version. Please feel free to ask questions.

Support

I have only tested this using python 3.6

Install

Download psbt.py and bitcoin_lib.py and place together in desired directory. bitcoin_lib.py is needed for parsing/serializing of transactions and scripts, as well as some other general functions.

bitcoin_lib is a library of basic bitcoin functions that was primarily written as part of @jimmysong 's Programming Blockchain course and additionally augmented by parts of his pybtcfork claimer. I have made a few additions, mainly just for understanding of more script types.

Test Vectors

Optionally, you can also download test_psbt.py which contains all the test vectors here: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#Test_Vectors

Note that these test vectors are not exhaustive.

If you want some help in understanding a serialized PSBT, I made this iterative color-coded breakdown of the different test vectors: https://docs.google.com/document/d/1BUTC3dh89kaxJbjUUD-nb8WLZ4SBvd15ZdgMlZrx0f4/edit

Use

Instantiate either a Creator, Updater, Signer, Combiner, Input Finalizer or Transaction Extractor object depending on the responsibility of the entity.

Different PSBT roles have different requirements and scopes and should stick only to those. Take note of the argument types they expect.

At this time, most functions expect data arguments to be raw bytes. Any PSBT role that has a constructor that expects a PSBT as an argument, expects it to be in bytes.

You can parse a base64 encoded PSBT and get the base64 representation of one as well.

Index arguments are expected to be ints and at this time getting/adding sighash types is expected to be of type int

Future work

There is still work to do here, a lot of which is TODO tagged in comments. Currently there are a few assumptions made that can be limiting, which I will get to.

I would like more test vectors added as well. There should be more exhaustive testing of different input types.

I intend to trim down bitcoin_lib.py quite a bit or perhaps use something different. I chose it for now because I understand it the best.

python-psbt's People

Contributors

jason-les avatar

Stargazers

 avatar Fooooooooooox avatar  avatar Ronny A. Giron avatar Sam Korn avatar  avatar bitromortac avatar Tim White avatar Leon Johnson avatar freenancial avatar Lucas Moten avatar Kristaps Kaupe avatar  avatar Parikshit Sharma avatar Justin Moon avatar

Watchers

$BmM$ avatar

python-psbt's Issues

Naming issue - Typo

On line 345 of psbt.py , in the function b64_psbt, you use "serialized_psbt" but the function is named serialized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.