Giter Club home page Giter Club logo

bitcore-payment-code's Introduction

bitcore payment protocol

BIP47 Payment Code support for bitcore =======

NPM Package Build Status Coverage Status

A module for bitcore that implements Payment Code

Getting Started

This library is distributed in both the npm and bower packaging systems.

npm install bitcore-payment-code
bower install bitcore-payment-code
// Generating a Payment code and its notification address for Alice

var PaymentCode = require('bitcore-payment-code');

// Alice's extended private key: MasterPrivKey

var xPrivKey = MasterPrivKey.derive("m/47'/0'/0'"); // See BIP47 for details
var xPubKey = xPrivKey.hdPublicKey;


var alicePc = new PaymentCode([xPubKey]); // Generate a payment Code
//also, new PaymentCode([xPubKey0, ..., xPubKeyN], m)  // Multisig M-N

var serializedPaymentCode = alicePc.toString(); // PaymentCode to share

var aliceNotificationPubKey = alicePc.publicKey;  
var aliceNotificationAddress = aliceNotificationPubKey.toAddress();


// Making a payment to Bob
var paymentInfo = alice.makePaymentInfo(BobPaymentCode, xPrivKey, index, outpoint);

// Index is the alice->bob payment order
// outpoint is where in the transaction the public key will be exposed

// Sample output:
 { 
  publicKeys: [ '023ded791973898f6892cead1b62ba57b9e5dc6c45aeaf0f20813acec96540cec1' ],
  paymentAddress: '1AJ3gNTaJ96NBDcj4cVmPZVBB7sF9rVA31',
  notificationOutputs: [ '010003874d18c82ce5fa774d3cefa16129159cc893007015e5791c0e1d1edba8d4fec48654656a77d16a1c25aaf61423c56973f71d526aab8a10fcc6cb65f3f21c403d00000000000000000000000000' ],
  notificationAddresses: [ '14L2fpcYwQQMmJvVJeewyuvdGfi49HmCZY' ] }
  }

// Then alice needs to send a notification TX:
// .from should be a valid UTXO



// Then the TX should be broadcasted... And the actual payment sent to `paymentInfo.paymentAddress`
// For future payments, index should be incremented.


// ===================================================
// Bob retrieval of the payment....


// When Bob receives a TX on his notification address:

Contributing

See CONTRIBUTING.md on the main bitcore repo for information about how to contribute.

License

Code released under the MIT license.

Copyright 2015 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.

bitcore-payment-code's People

Contributors

matiu avatar isocolsky avatar

Stargazers

Ben Plunkert avatar Ali Mahdiyar avatar  avatar Rahman avatar Gábor Mihálcz avatar Rasikh Morani avatar Felipe Monteiro avatar

Watchers

 avatar Gustavo avatar D avatar James Cloos avatar Justus Ranvier avatar Ben Plunkert 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.