Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation #15

Merged
merged 7 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
*.sw[a-z]
coverage
# do not track dependencies
node_modules
bitcore-payment-protocol.js
bitcore-payment-protocol.min.js
tests.js

lib/errors/index.js
npm-debug.log

bower_components
report
.DS_Store
# ignore generated code coverage output
coverage
.nyc_output

.idea/
# ignore build artifacts
dist
74 changes: 59 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
Dashcore Payment Protocol
==============================
# Dashcore Payment Protocol

[![NPM Package](https://img.shields.io/npm/v/@dashevo/dashcore-payment-protocol.svg?style=flat-square)](https://www.npmjs.org/package/@dashevo/dashcore-payment-protocol)
[![Build Status](https://img.shields.io/travis/dashevo/dashcore-payment-protocol.svg?branch=master&style=flat-square)](https://travis-ci.org/dashevo/dashcore-payment-protocol)
[![Coverage Status](https://img.shields.io/coveralls/dashevo/dashcore-payment-protocol.svg?style=flat-square)](https://coveralls.io/r/dashevo/dashcore-payment-protocol)
[![Build Status](https://img.shields.io/travis/dashevo/dashcore-payment-protocol.svg?branch=master)](https://travis-ci.org/dashevo/dashcore-payment-protocol)
[![NPM Package](https://img.shields.io/npm/v/@dashevo/dashcore-payment-protocol.svg)](https://www.npmjs.org/package/@dashevo/dashcore-payment-protocol)

A module for [dashcore](https://github.com/dashevo/dashcore) that implements [Payment Protocol](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki) and other related BIPs.
A module for [dashcore-lib](https://github.com/dashevo/dashcore-lib) that implements [Payment Protocol](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki) and other related BIPs.

## Getting Started

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

```sh
npm install dashcore-lib
npm install dashcore-payment-protocol
npm install @dashevo/dashcore-lib
npm install @dashevo/dashcore-payment-protocol
```

There are many examples of how to use it on the developer guide [section for payment protocol](https://bitcore.io/api/paypro). For example, the following code would verify a payment request:

```javascript
const PaymentProtocol = require('dashcore-payment-protocol');
const PaymentProtocol = require('@dashevo/dashcore-payment-protocol');

const body = PaymentProtocol.PaymentRequest.decode(rawbody);
const request = new PaymentProtocol().makePaymentRequest(body);
Expand All @@ -34,12 +30,60 @@ const signature = pr.get('signature');
const verified = request.verify();
```

## Release

### Publishing to NPM

To publish this package to NPM, first install and ensure all tests passing.

```sh
npm install
npm run test
npm run coverage # to also check coverage
```

Also, browser bundle must be built, and it's a good idea to re-generate root
SSL certs which are packaged with this module every once in a while:

```sh
npm run build
npm run rootcerts
```

Don't forget to bump the version in `package.json` and `package-lock.json`
using whatever method is easiest.

Once all that is done, package maintainers can publish:

```sh
npm publish
```

### GitHub Release Follow-Up

A tag should be pushed to github once published:

```sh
git tag v1.2.3 && git push origin v1.2.3
```

And in order to ensure a common ancestor commit, develop should be
fast-forwarded to master and pushed:

```sh
git checkout develop && git merge --ff master && git push origin develop
```

### Note

Ideally we build a tag-based release process into the GitHub / CI integration
so that pushing a tag to GitHub will automatically perform all the above steps
in order to publish the module to NPM.

## Contributing

See [CONTRIBUTING.md](https://github.com/dashevo/dashcore/blob/master/CONTRIBUTING.md) on the main dashcore repo for information about how to contribute.
Feel free to dive in! [Open an issue](https://github.com/dashevo/dashcore-payment-protocol/issues/new) or submit PRs.

## License

Code released under [the MIT license](https://github.com/dashevo/dashcore/blob/master/LICENSE).

Copyright 2013-2015 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.
[MIT](LICENSE) © Dash Core Group, Inc.
26 changes: 13 additions & 13 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
# Payment Protocol

`PaymentProtocol` and associated functions and methods will serialize, deserialize, sign and verify payment protocol messages both in Node.js and web browsers. Both X.509 and [bitcoin identity protocol](https://en.bitcoin.it/wiki/Identity_protocol_v1) are supported. For detailed technical information, please view [BIP70](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki).

## Installation
Payment protocol is implemented as a separate module and you must add it to your dependencies:

For node projects:

```
npm install bitcore-lib --save
npm install bitcore-payment-protocol --save
```

For client-side projects:
Payment protocol is implemented as a separate module and you must add it to your dependencies:

```
bower install bitcore-lib --save
bower install bitcore-payment-protocol --save
npm install @dashevo/dashcore-lib
npm install @dashevo/dashcore-payment-protocol
```
Copy link

@Cofresi Cofresi Jan 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm install @dashevo/dashcore-lib
npm install @dashevo/dashcore-payment-protocol


## Make Payment Details

Here the merchant's server will construct the payment details message:

```javascript
var PaymentProtocol = require('bitcore-payment-protocol');
var PaymentProtocol = require('@dashevo/dashcore-payment-protocol');
var now = Date.now() / 1000 | 0;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var PaymentProtocol = require('@dashevo/dashcore-payment-protocol');

// construct the payment details
Expand All @@ -39,6 +33,7 @@ details.set('merchant_data', new Buffer({size: 7})); // identify the request
For more information about these fields please visit [BIP70](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki#paymentdetailspaymentrequest)

## Sign a Payment Request

The merchant's server will then construct a payment request and send it to the customer:

```javascript
Expand All @@ -64,6 +59,7 @@ var rawbody = request.serialize();
```

## Verify a Payment Request

The customers wallet would then verify the payment request as follows (after asking for the payment request message):

```javascript
Expand Down Expand Up @@ -99,6 +95,7 @@ var merchant_data = details.get('merchant_data');
```

## Send a Payment

After the request is verified a payment can be sent to the merchant from the customer's wallet:

```javascript
Expand Down Expand Up @@ -130,6 +127,7 @@ var rawbody = pay.serialize();
```

## Receive a Payment

The merchant would then receive the payment as follows:

```javascript
Expand All @@ -141,10 +139,11 @@ var transactions = payment.get('transactions');
var refund_to = payment.get('refund_to');
var memo = payment.get('memo');

// send the transaction to the bitcoin network
// send the transaction to the Dash network
```

## Send a Payment Acknowledgement

After the payment has been broadcasted, a payment acknowledgement can be sent in response:

```javascript
Expand All @@ -162,6 +161,7 @@ var rawbody = ack.serialize();
```

## Receive an Acknowledgement

The customer's wallet can then receive an acknowledgement of payment as follows:

```javascript
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@dashevo/dashcore-payment-protocol",
"version": "1.7.0",
"description": "Payment Protocol (BIP70 and related) support for dashcore",
"author": "BitPay <dev@bitpay.com>",
"author": "Dash Core Group, Inc. <dev@dash.org>",
"main": "index.js",
"scripts": {
"lint": "eslint .",
Expand Down