rn-bitcoinjs-message
v0.0.1
Published
A javascript Bitcoin library for react-native
Downloads
5
Readme
bitcoinjs-message
Examples
var bitcoin = require('bitcoinjs-lib') // v3.x.x
var bitcoinMessage = require('bitcoinjs-message')
sign(message, privateKey, compressed[, network.messagePrefix])
Sign a Bitcoin message
var keyPair = bitcoin.ECPair.fromWIF('5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss')
var privateKey = keyPair.privateKey
var message = 'This is an example of a signed message.'
var signature = bitcoinMessage.sign(message, privateKey, keyPair.compressed)
console.log(signature.toString('base64'))
// => 'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk='
verify(message, address, signature[, network.messagePrefix])
Verify a Bitcoin message
var address = '1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN'
console.log(bitcoinMessage.verify(message, address, signature))
// => true