Skip to content
/ wif Public

Bitcoin Wallet Import Format JS encoding/decoding module

License

Notifications You must be signed in to change notification settings

bitcoinjs/wif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6a6965b · Jun 25, 2024

History

97 Commits
Jun 25, 2024
Jun 25, 2024
Jun 25, 2024
Jun 25, 2024
Jun 25, 2024
Aug 20, 2015
Jun 25, 2024
Jun 25, 2024
Jun 25, 2024
Jun 25, 2024
Jun 25, 2024
Jun 25, 2024

Repository files navigation

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