Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including bitcoin-buffer with all npm packages installed. Try it out:

var bitcoinBuffer = require("bitcoin-buffer")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bitcoin-buffer v0.4.0

Buffer functions for bitcoin apps

Buffer functions for Bitcoin applications

Installation

`npm install bitcoin-buffer

Example

var utils = require('bitcoin-buffer')

var buf = new Buffer(8)

utils.writeUInt64LE(buf, 1, 0)
// buf = 0100000000000000

utils.writeVarInt(buf, 0xffffff, 0)
// buf = feffffff00

API

writeUInt64LE(buf, value, offset)

Writes in buf

readUInt64LE(buf, offset)

returns an integer

numToVarInt(value)

returns a Buffer

readVarInt(buf, offset)

returns an object of this format { res: value, offset: offset }

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free