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

abstract-common-wallet

v1.4.1

Published

A test suite and interface you can use to ensure standard Bitcoin wallet functionality.

Downloads

32

Readme

abstract-common-wallet

A test suite and interface you can use to implement standard Common Wallet powered applications.

Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite. For example, s3-blob-store uses abstract-blob-store, and so does torrent-blob-store, bitstore-blob-store and many others.

Using this module will help to create easy to consume APIs for dealing with bitcoin wallets.

How to use

To use the test suite from this module you can require('abstract-common-wallet/tests')

An example of this can be found in the test-common-wallet test suite.

You have to implement a setup and teardown function after declaring your common wallet object:


// test-common-wallet is a simple to use wallet for intended for use in tests
var testCommonWallet = require('test-common-wallet');

// our wallet benefits from being able to interface with the blockchain
var commonBlockchain = require('blockcypher-unofficial')({
  network: "testnet",
  inBrowser: true
});

// we seed our wallet with the same text to generate the same bitcoin wallet address
var commonWallet = testCommonWallet({
  network: "testnet",
  commonBlockchain: commonBlockchain,
  seed: "someTextSeed"
});

// and then we check to see if our wallet passes all of the tests and adheres to the protocol
var common = {
  setup: function(t, cb) {
    cb(null, commonWallet);
  },
  teardown: function(t, commonWallet, cb) {
    cb();
  }
}

To run the tests simply pass your test module (tap or tape or any other compatible modules are supported), the seed you used to generate your commonWallet Object, and your common methods in:

var abstractCommonWalletTests = require('abstract-common-wallet/tests')
abstractCommonWalletTests(test, seed, common)

A valid common wallet interface should implement the following functions.

Functions

//callback should be of the form (err, response)
cw.signMessage("hey there, this is a message", callback);

//this callback should be of the form (err, signedTxHex, txid)
cw.signTransaction((some unsigned transaction hex to sign), callback);

//will create, sign, and (optionally) propagate a transaction. callback should be of (err, response)
cw.createTransaction({
  value: (the amount of btc to be transacted in satoshi),
  destinationAddress: (the address your Common Wallet object will be sending btc to),
  propagate: (true or false if you want to propagate the tx. Will default to false)
}, callback);

//will login to a compatible back-end server using wallet address as an identifier
cw.login(host, callback);

//will send authenticated requests to compatible back-end server
cq.request(options, callback);

Other Common Wallet Data

In addition to the three functions listed above, a common wallet object will also have these two fields:

  address: (the public address of the wallet)
  network: (the network the wallet is operating on)