Code Monkey home page Code Monkey logo

offline-bch-transaction's Introduction

Offline BCH Transactions

A python implementation of an offline Bitcoin Cash transaction

Prerequisite

Only the BitCash python libraries are needed. BitCash is a powerful python library for the Bitcoin Cash (BCH) network that neatly encapsulates a lot of the blockchain development complexities. It was inspired by Requests and Keras, and was forked from the Bitcoin (BTC) 'Bit' python library.

If you're unfamiliar with BitCash please checkout Corentin Mercier's guide.

Install the BitCash python libraries

pip install bitcash

Offline Transaction Demo

  1. Clone the repo
git clone https://github.com/fifikobayashi/Offline-BCH-Transaction
  1. Update the transaction parameters in build_tx.py such as transfer currency, amount, target address... etc
# Transaction parameters
transferCurrency = 'bch'
transferAmount 	 = 0.0001
txDataFile	 = 'offlineTxData.json'
txHexFile	 = 'offlineTxHex.json'
receivingAddress = 'n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi'
  1. Run build_tx.py which will take in the transaction parameters and generate a offlineTxData.JSON file
python3 build_tx.py
  1. The sign_tx() function within build_tx.py simulates the physical step of taking the generated tx data JSON file to, say, an air-gapped terminal or to an area in Africa with no internet access. The function reads the JSON file, signs the transaction and writes the output to a offlineTxHex.JSON file.

  2. Run broadcast_tx.py which will take in the tx hex JSON generated by sign_tx() and broadcasts it onto the BCH network.

python3 broadcast_tx.py
  1. Lookup the sending address on the BCH testnet explorer to verify it has been added to the mempool.

offline-bch-transaction's People

Contributors

fifikobayashi avatar

Stargazers

BA.net avatar James Burrell, II avatar

Watchers

James Cloos avatar  avatar

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.