Coder Social home page Coder Social logo

cryptobuks / test-common-wallet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blockai-unofficial/test-common-wallet

0.0 2.0 0.0 108 KB

A simple common wallet object used in tests for software that supports the common wallet standard.

JavaScript 100.00%

test-common-wallet's Introduction

test common wallet

A test Common Wallet object for testing software written to the commonWallet spec.

Inputs

Note common wallet relies on a common blockchain client which can be found here A common wallet instance can be instantiated as follows:

var cw = require('test-common-wallet')({
  network: (network you want to operate on. "testnet" or "mainnet"),
  wif: (your private key in wif format to sign messages and transactions),
  commonBlockchain: (a Common Blockchain client. Read about this in the link above)
});

or

var cw = require('test-common-wallet')({
  network: (network you want to operate on. "testnet" or "mainnet"),
  seed: (a seed to generate a wif ie: "this is a seed"),
  commonBlockchain: (a Common Blockchain client. Read about this in the link above)
});

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 authenticate with host using wallet address as id
cw.login(host, function(err, res, body) {
  
});

//wraps npm request module with wallet authentication with host, use login() first
cw.request(options, function(err, res, body) {

});

Authentication

Use express-common-wallet middleware with login() and request() functions.

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)

test-common-wallet's People

Contributors

andrewmalta13 avatar williamcotton avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.