npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simplebtc

v6.1.0

Published

High-level Bitcoin library and command line tool

Downloads

79

Readme

simplebtc

High-level Bitcoin library and command line tool; originally created for Token, currently used by Cyph.

For complete API documentation, read the type declaration file.

Import

	import {Wallet} from 'simplebtc';

Constructor

	const wallet = new Wallet(/* {
		address: '1E4G7mwKozrTSUijjB2eFqgbU9zxToZbkz',
		key: 'L4udA8nLC1r2xCVuzretgKuAZkvQq2aCZWKgiGXrxWEcH956xeE2',
		localCurrency: 'USD'
	} */);

If a WIF key is specified, it will be used to derive the private key and address, and money may be sent from the wallet.

Otherwise, an address may be specified, in which case no private key will be generated and the wallet will be read-only.

If neither a WIF nor an address is specified, a new wallet with a new private key and address will be generated. This will not be read-only, but it will start off with a balance of 0 BTC.

Address

	wallet.address	// 1E4G7mwKozrTSUijjB2eFqgbU9zxToZbkz

Command line:

	$ simplebtc address

Balance

	const balance = await wallet.getBalance();

	// balance == {btc: 0.0482, local: 30}

Command line:

	$ simplebtc balance

Transactions

	const transactions = await wallet.getTransactionHistory();

	/* transactions == [{
		amount: 76.92,
		id: 'cf046a7e3303a7b44f86e4bb92367b4ae223e2c76dd0b45346de879acd482905',
		isConfirmed: true,
		recipients: ['1L8wTTMxSUw2vYmQb4xr9r4M1g8n2YFcgX'],
		senders: ['1E4G7mwKozrTSUijjB2eFqgbU9zxToZbkz'],
		timestamp: 1407970572000,
		wasSentByMe: true
	}, ...] */

Command line:

	$ simplebtc history

Handle Receiving Money

	wallet.watchNewTransactions().subscribe(transaction => {
		console.log(transaction);
	});

	/* transaction == {
		amount: 76.92,
		id: 'cf046a7e3303a7b44f86e4bb92367b4ae223e2c76dd0b45346de879acd482905',
		isConfirmed: true,
		recipients: ['1L8wTTMxSUw2vYmQb4xr9r4M1g8n2YFcgX'],
		senders: ['1E4G7mwKozrTSUijjB2eFqgbU9zxToZbkz'],
		timestamp: 1407970572000,
		wasSentByMe: true
	} */

Command line:

	$ simplebtc stream

Send Money

	await wallet.send('1BTCorgHwCg6u2YSAWKgS17qUad6kHmtQW', 30);

	// $30 sent to Bitcoin Foundation

Command line:

	$ simplebtc send [recipient address] [amount in local currency]

If available, this method will deduct the transaction fee in addition to the specified amount; otherwise, the fee will be subtracted from the amount being sent.

Similar to Bitcoin Core, unspent transaction outputs which originated locally will be treated as confirmed.

Export Wallet to WIF

	wallet.key.toWIF()	// L4udA8nLC1r2xCVuzretgKuAZkvQq2aCZWKgiGXrxWEcH956xeE2

Install

	$ npm install simplebtc