bitcoin sign utils
small lib to make sign message and access wallet from mnemonic based on bip32 & bip39 from NovaCrypto
npm install https://github.com/vuongpsht/rn-btc-fast-sign-message.git
import Bitcoin from "react-native-bitcoin";
interface WalletInfo {
address: string,
mnemonics: string,
privateKey: string,
publicKey: string,
root32xprv: string
}
// ...
const wallet: WalletInfo = await Bitcoin.generateMnemonic()
// or
const mnemonics = "whip position jazz switch where cupboard leader slice nephew unusual hand maple"
const walletFromMnemonic: WalletInfo = await Bitcoin.mnemonicToWallet(mnemonics)
// address: "bc1q2cxk23lns53p6y5f7ht2kf04r7myr06w0uh3su", <- address as bip84
// mnemonics: "whip position jazz switch where cupboard leader slice nephew unusual hand maple", <- mnemonic when generate
// privateKey: "L35esJKrpKByKh7CiDUaD1bkCbUi65SWXY4xfYJNWLFMvhSzXKJX", <- privatekey as bip84
// publicKey: "0295ba81e1ed4c09441b1ea62cb9d25318ecad29b6e3d425dfb5d071a0a948da29", <- publickey as bip84
// root32xprv: "xprv9s21ZrQH143K27UcMoKcw3CJMjaztFWmqkUHh4igNcZBNkvTQy5dYgmUkXxfrDMGb4p8QdbcNHKHQeHuMwA8bvM6BvKR56hYY6JPTncdFQK" <- root bip32 xprv
you can use with bitcoinjs-message it will look like
const msg = "this is a simple message"
const child = bitcoin.bip32.fromBase58(wallet.root32xprv, bitcoin.networks.bitcoin).derivePath("m/84'/0'/0'/0/0")
const signature = bitcoinMessage
.sign(message, child.privateKey, true, {segwitType: 'p2wpkh'})
.toString('base64')
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT