bitcoinjs / wif

Bitcoin Wallet Import Format JS encoding/decoding module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WIF

TRAVIS NPM

js-standard-style

Bitcoin Wallet Import Format encoding/decoding module.

Example

import * as wif from "wif"
var privateKey = Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
var key = wif.encode({version: 128, privateKey, compressed: true}) // for the testnet use: wif.encode(239, ...
// => KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn

var obj = wif.decode(key)
// => {
//	version: 128,
//	privateKey: Uint8Array(32) [
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 1
//   ],
//	compressed: true
//}

wif.decode(key, 0x09)
// => Error: Invalid network version

// alternative syntax
wif.encode(obj)
// => KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn

LICENSE MIT

About

Bitcoin Wallet Import Format JS encoding/decoding module

License:MIT License


Languages

Language:JavaScript 76.4%Language:TypeScript 23.6%