Code Monkey home page Code Monkey logo

rn-btc-fast-sign-message's Introduction

rn-btc-fast-sign-message

bitcoin sign utils

small lib to make sign message and access wallet from mnemonic based on bip32 & bip39 from NovaCrypto

Installation

npm install https://github.com/vuongpsht/rn-btc-fast-sign-message.git

Usage

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')

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.