Coder Social home page Coder Social logo

build-output-script's Introduction

build-output-script

Builds a P2PKH Bitcoin transaction output script

Build Status Coverage Status npm tippin.me

Builds a P2PKH Bitcoin transaction output script from an array of P2PKH addresses and amounts. Will also work with any Bitcoin derived cryptocurrencies with a single byte pubkey hash address prefix.

The output script is returned as a hex string and can be passed directly in to ledgerjs.

Install

npm install build-output-script

Usage

Send 1 BTC to 1LukeQU5jwebXbMLDVydeH4vFSobRV9rkj

const buildOutputScript = require('build-output-script');

buildOutputScript([{address: '1LukeQU5jwebXbMLDVydeH4vFSobRV9rkj', value: 100000000}]);
// '0100e1f505000000001976a914da6473ed373e08f46dd8003fca7ba72fbe9c555e88ac'

Send 1 BTC to 1LukeQU5jwebXbMLDVydeH4vFSobRV9rkj and 1 BTC to 1BitcoinEaterAddressDontSendf59kuE

buildOutputScript([
  {address: '1LukeQU5jwebXbMLDVydeH4vFSobRV9rkj', value: 100000000},
  {address: '1BitcoinEaterAddressDontSendf59kuE', value: 100000000}
]);
// '0200e1f505000000001976a914da6473ed373e08f46dd8003fca7ba72fbe9c555e88ac00e1f505000000001976a914759d6677091e973b9e9d99f19c68fbf43e3f05f988ac'

Send 1 LTC to Lf8hucmupbtenQ3VPdxvvJ8gTfAsaon2gf

buildOutputScript([{address: 'Lf8hucmupbtenQ3VPdxvvJ8gTfAsaon2gf', value: 100000000}]);
// '0100e1f505000000001976a914da6473ed373e08f46dd8003fca7ba72fbe9c555e88ac'

API

buildOutputScript(outputs)

Returns a (hex string) P2PKH transaction output script.

outputs

Type: Array(output[, output])

An array of one or more output objects.

output.address

Type: String

A valid P2PKH address.

output.value

Type: Number

Value to send to address in satoshis.

License

MIT © Luke Childs

build-output-script's People

Contributors

lukechilds avatar

Watchers

James Cloos 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.