Git Product home page Git Product logo

bitcoin-reorg-compatibility-toy's Introduction

bitcoin-reorg-compatibility-toy

bitcoin-reorg-compatibility-toy is a small python project to demonstrate the concept of "reorg-compatibility". Any software implementing a Bitcoin service must be reorg-compatible except in the most mundane and stateless scenarios. Reorg-compatibility is when software is written in a way that aggressively correctly handles reorgs. Although reorg-compatibility has many benefits, in general it is good to prefer architecture that does not need to be concerned with blockchain reorganizations.

Usage

Installing development dependencies

See requirements-dev.apt for a list of packages required to develop and work with the software in this repository. Basically just run something like:

sudo apt-get install -y $(cat ./requirements-dev.apt)

Building the docker container

make build

Words of caution

Only one docker container?

The toy in this repo is used in a docker container that runs bitcoind as well as the example software. This is a bad idea and it is not recommended.

Private keys

Never store private keys in production.

License

BSD

bitcoin-reorg-compatibility-toy's People

Contributors

kanzure avatar

Stargazers

 avatar

Watchers

 avatar  avatar

bitcoin-reorg-compatibility-toy's Issues

Serialized transaction plan

Last known serialized unspent transaction output

When a deposit transaction is detected even with zero-confirms, make a transaction that spends the deposited unspents with a transaction that also spends the previous serialized unspent transaction output (SUTXO). This new transaction is now the latest serialized unspent transaction output. When creating the next withdrawal transaction, reference the latest serialized unspent transaction output in the same transaction.

Implementation details

  • When a deposit is received, create a new transaction to move the deposit to a change address while also including the SUTXO.
  • When the network mutates that last transaction, generate another transaction that spends the same outputs. This should be generally true for any type of transaction that is created.
  • When a deposit goes missing (not mutated, just gone) (like because of a reorg), either halt the system or generate a plan for which other transactions to continue to make or exclude from the signing process....

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.