Skip to content

andrewmalta13/abstract-common-wallet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

var testCommonWallet= require('../'); //or require('test-common-wallet')
var commonWallet = testCommonWallet({
  network: "testnet",
  commonBlockchain: commonBlockchain,
  seed: (some seed for your wallet's private key.)
});

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

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)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published