Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wallet.ts

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wallet.ts

Utilities for cryptocurrency wallets, written in TypeScript

  • 0.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
342
increased by107.27%
Maintainers
1
Weekly downloads
 
Created
Source

wallet.ts

npm version Downloads

A collection of utilities for building cryptocurrency wallets, written in TypeScript.

Hierarchical Deterministic Wallets (BIP 32)

const { randomBytes } = require('crypto')
const { HDKey } = require('wallet.ts')

const seed = randomBytes(66)

const masterKey = HDKey.parseMasterSeed(seed)
// => HDKey {...}

const extendedPrivateKey = masterKey.derive("m/44'/60'/0'/0").extendedPrivateKey
// => 'xprvA2FBfTJAyLjF5 ...'

const childKey = HDKey.parseExtendedKey(extendedPrivateKey)
// => HDKey {...}

const wallet = childKey.derive('0')
// => HDKey {...}

const walletPrivateKey = wallet.privateKey
// => <Buffer 44 04 ce 4a ...>

const walletPublicKey = wallet.publicKey
// => <Buffer 03 e9 f6 10 ...>

View Source

Mnemonic code for generating deterministic keys (BIP 39)

const { randomBytes } = require('crypto')
const { Mnemonic } = require('wallet.ts')

const mnemonic = Mnemonic.generate(randomBytes(32))
// => Mnemonic {...}

const phrase = mnemonic.phrase
// => 'capital find public couple ...'

const words = mnemonic.words
// => [ 'capital', 'find', 'public', 'couple', ...]

const seed = mnemonic.toSeed()
// => <Buffer cd 07 60 43 ...>

View Source

Bitcoin Address

const { BitcoinAddress } = require('wallet.ts')

const publicKey = Buffer.from(
  '0250863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352',
  'hex'
)

const address = BitcoinAddress.from(publicKey).address
// => '16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM'

const valid = BitcoinAddress.isValid(address)
// => true

View Source

Ethereum Address / EIP 55 checksum

const { EthereumAddress } = require('wallet.ts')

const publicKey = Buffer.from(
  '028a8c59fa27d1e0f1643081ff80c3cf0392902acbf76ab0dc9c414b8d115b0ab3',
  'hex'
)

const address = EthereumAddress.from(publicKey).address
// => 0xD11A13f484E2f2bD22d93c3C3131f61c05E876a

const valid = EthereumAddress.isValid(address)
// => true

const checksumAddress = EthereumAddress.checksumAddress('0xd11a13f484e2f2bd22d93c3c3131f61c05e876a')
// => 0xD11A13f484E2f2bD22d93c3C3131f61c05E876a

View Source


Copyright © 2017 Peter Jihoon Kim. This project is licensed under the ISC license.

Keywords

FAQs

Package last updated on 30 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc