• Stars
    star
    105
  • Rank 328,196 (Top 7 %)
  • Language
    TypeScript
  • License
    ISC License
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utilities for cryptocurrency wallets, written in TypeScript

wallet.ts

npm version Downloads CI

A collection of utilities for building cryptocurrency wallets, written in TypeScript. Requires Node.js 12.0.0+.

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

Ethereum Address / EIP 55 checksum

const { EthereumAddress } = require("wallet.ts");

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

const address = EthereumAddress.from(publicKey).address;
// => "0xD11A13f484E2f2bD22d93c3C3131f61c05E876a9"

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

const checksumAddress = EthereumAddress.checksumAddress(
  "0xd11a13f484e2f2bd22d93c3c3131f61c05e876a9"
);
// => "0xD11A13f484E2f2bD22d93c3C3131f61c05E876a9"

View Source

Bitcoin Address (deprecated)

const { BitcoinAddress } = require("wallet.ts");

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

const address = BitcoinAddress.from(publicKey).address;
// => "1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs"

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

View Source


Copyright © 2018-2020 Coinbase, Inc.

Copyright © 2017-2018 HardFork Inc.

This project is licensed under the ISC license.

More Repositories

1

goop

A simple dependency manager for Go (golang), inspired by Bundler.
Go
780
star
2

ConciseKit

A set of Objective-C additions and macros that helps you write code more quickly.
Objective-C
555
star
3

metamask-mobile

Port of MetaMask Ethereum Ðapp browser for mobile devices (iOS only for now)
JavaScript
134
star
4

factory-lady

a factory library for node.js / javascript inspired by factory_girl
JavaScript
119
star
5

cipher-ethereum

A typed and fully-tested Ethereum library used by Cipher Browser, a mobile Ethereum wallet and Dapp browser
TypeScript
82
star
6

autoparts

package manager for nitrous.io
Ruby
81
star
7

socks

An easy-to-use web GUI toolkit for JavaScript, inspired by Shoes
65
star
8

ot.go

Operational Transformation backend written in Go compatible with ot.js
Go
36
star
9

underscore.objc

work in progress...
Objective-C
27
star
10

nitrogen-dist

Nitrogen: Atom, meet Cloud.
CSS
13
star
11

hterm

ChromiumOS hterm
JavaScript
9
star
12

ResetColorProfileAfterWake

Fix macOS bug that causes display color to get messed up after waking device from sleep
Objective-C
7
star
13

rubb

BBCode Parser for Ruby that supports nested BBCode tags.
Ruby
5
star
14

railscasts_xcode_color_theme

Railscasts Xcode color theme
5
star
15

dart-ethereum_address

A dart library to generate and validate Ethereum addresses
Dart
4
star
16

dotfiles

Vim Script
4
star
17

pubstorm-server

PubStorm API server
Go
3
star
18

usdc-l2-demo

USDC L2 Demo
TypeScript
3
star
19

tinymongo

Simple MongoDB wrapper
Ruby
2
star
20

ens-dnsname

Encode and decode DNS names for ENS using Golang
Go
2
star
21

skeleton

skeleton rails app for pairing interviews
Ruby
2
star
22

pubstorm-cli-go

PubStorm command line client
Go
1
star
23

go.vim

vim.go Vim plugins for Go (http://golang.org) - Extracted from Go official tarball.
1
star
24

rise-nginx

Lua
1
star
25

useful-ios-tidbits

a collection of useful ios code tidbits
Objective-C
1
star
26

fiat-token-gas-relay

TypeScript
1
star
27

petejkim.github.com

JavaScript
1
star
28

vim-colors-solarized-24bit-terminal

Vim Script
1
star
29

empty

1
star