From d23e6307372eba8442eb5b13519c74231de1f64e Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 16 Apr 2018 11:25:13 +1000 Subject: [PATCH 1/7] add CONTRIBUTING.md --- CONTRIBUTING.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 4 +-- 2 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..8fc283f78 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,71 @@ +# Contributing to bitcoinjs-lib + +Firstly in terms of structure, there is no particular concept of "bitcoinjs developers" in the sense of privileged people. +Open source often naturally revolves around meritocracy where longer term contributors gain more trust from the developer community. + +However, for practical purpose, there are repository "maintainers" who are responsible for merging pull requests. + +We are always accepting of pull requests, but we do adhere to specific standards in regards to coding style, test driven development and commit messages. + + +## Communication Channels +GitHub is the preferred method of communication between members. + +Otherwise, in order of preference: +* bitcoinjs.slack.com +* #bitcoinjs-dev on Freenode IRC + + +## Workflow +The codebase is maintained using the "contributor workflow" where everyone without exception contributes patch proposals using "pull requests". +This facilitates social contribution, easy testing and peer review. + +To contribute a patch, the workflow is as follows: + + 1. Fork repository + 1. Create topic branch + 1. Commit patches + 1. Push changes to your fork + 1. Submit a pull request to https://github.com/bitcoinjs/bitcoinjs-lib + +[Commits should be atomic](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) and diffs easy to read. + +If your pull request is accepted for merging, you may be asked by a maintainer to squash and or [rebase](https://git-scm.com/docs/git-rebase) your commits before it will be merged. + +Please refrain from creating several pull requests for the same change. + +Patchsets should be focused: + + * Adding a feature, or + * Fixing a bug, or + * Refactoring code. + +If you combine these, the PR may be rejected or asked to be split up. + +The length of time required for peer review is unpredictable and will vary from pull request to pull request. + +Refer to the [Git manual](https://git-scm.com/doc) for any information about `git`. + +## We adhere to Bitcoin-Core policy +- `bitcoinjs.template.*` functions should follow the script "templates" typically used in the community (and consequently, the bitcoin blockchain). + +This is a matter of community consensus, but is probably going to always be closely related to what bitcoin core does by default. +They are quite plainly just pattern matching functions, and should be treated as such. + +`bitcoinjs.script.decompile` is consensus bound only, it does not reject based on policy. +`bitcoinjs.script.compile` will adhere to bitcoin-core `IsStandard` policies rules. (eg. minimalpush in https://github.com/bitcoinjs/bitcoinjs-lib/pull/638) + +ECDSA `sign` operations will adhere to `IsStandard` policies such as `LOW_S`, but `verify` will not reject them. + +For rejecting non-standard `decoding`, you should use external modules to this library. + +**TLDR:** +Where "standards compliant" refers to the default policies of bitcoin-core, we adhere to the following: +- Any "creation" event must create standards-compliant data (standards bound) +- Any "validation" event must allow for non-standards compliant data (consensus bound) + +For stricter validation, use an external module which we [might have] provided. + + +## Release Policy +TODO diff --git a/README.md b/README.md index 14faf3d10..77b4455dd 100644 --- a/README.md +++ b/README.md @@ -163,9 +163,7 @@ If you have a use case that you feel could be listed here, please [ask for it](h ## Contributing -We are always accepting of pull requests, but we do adhere to specific standards in regards to coding style, test driven development and commit messages. - -Please make your best effort to adhere to these when contributing to save on trivial corrections. +See [CONTRIBUTING.md](CONTRIBUTING.md). ### Running the test suite From 616c876c1c959baf29c242bb38feb3bbb8a20a69 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 21 Jun 2018 12:38:10 +1000 Subject: [PATCH 2/7] CONTRIB: add bitcoin/bitcoin text attribution and cleanup --- CONTRIBUTING.md | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fc283f78..efc9caebf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,11 @@ -# Contributing to bitcoinjs-lib -Firstly in terms of structure, there is no particular concept of "bitcoinjs developers" in the sense of privileged people. -Open source often naturally revolves around meritocracy where longer term contributors gain more trust from the developer community. +[//]: # (This is partially derived from https://github.com/bitcoin/bitcoin/blob/6579d80572d2d33aceabbd3db45a6a9f809aa5e3/CONTRIBUTING.md) + +# Contributing to bitcoinjs-lib +Firstly in terms of structure, there is no particular concept of "bitcoinjs developers" in a sense of privileged people. +Open source revolves around a meritocracy where contributors who help gain trust from the community. -However, for practical purpose, there are repository "maintainers" who are responsible for merging pull requests. +For practical purpose, there are repository "maintainers" who are responsible for merging pull requests. We are always accepting of pull requests, but we do adhere to specific standards in regards to coding style, test driven development and commit messages. @@ -30,7 +32,7 @@ To contribute a patch, the workflow is as follows: [Commits should be atomic](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) and diffs easy to read. -If your pull request is accepted for merging, you may be asked by a maintainer to squash and or [rebase](https://git-scm.com/docs/git-rebase) your commits before it will be merged. +If your pull request is accepted for merging, you may be asked by a maintainer to squash and or [rebase](https://git-scm.com/docs/git-rebase) your commits before it is merged. Please refrain from creating several pull requests for the same change. @@ -46,26 +48,20 @@ The length of time required for peer review is unpredictable and will vary from Refer to the [Git manual](https://git-scm.com/doc) for any information about `git`. -## We adhere to Bitcoin-Core policy -- `bitcoinjs.template.*` functions should follow the script "templates" typically used in the community (and consequently, the bitcoin blockchain). -This is a matter of community consensus, but is probably going to always be closely related to what bitcoin core does by default. -They are quite plainly just pattern matching functions, and should be treated as such. +## We adhere to Bitcoin-Core policy +Bitcoin script payment/script templates are based on community consensus, but typically adhere to bitcoin-core node policy by default. -`bitcoinjs.script.decompile` is consensus bound only, it does not reject based on policy. -`bitcoinjs.script.compile` will adhere to bitcoin-core `IsStandard` policies rules. (eg. minimalpush in https://github.com/bitcoinjs/bitcoinjs-lib/pull/638) +- `bitcoinjs.script.decompile` is consensus bound only, it does not reject based on policy. +- `bitcoinjs.script.compile` will try to adhere to bitcoin-core `IsStandard` policies rules. (eg. minimalpush in https://github.com/bitcoinjs/bitcoinjs-lib/pull/638) -ECDSA `sign` operations will adhere to `IsStandard` policies such as `LOW_S`, but `verify` will not reject them. +Any elliptic curve `sign` operations should adhere to `IsStandard` policies, like `LOW_S`, but `verify` should not reject them [by default]. -For rejecting non-standard `decoding`, you should use external modules to this library. +If you need non-standard rejecting `decoding`, you should use an external module, not this library. -**TLDR:** +#### TLDR Where "standards compliant" refers to the default policies of bitcoin-core, we adhere to the following: - Any "creation" event must create standards-compliant data (standards bound) - Any "validation" event must allow for non-standards compliant data (consensus bound) -For stricter validation, use an external module which we [might have] provided. - - -## Release Policy -TODO +For stricter validation, use an external module which we [may have] provided. From b8a519224e9c4f67611869a926354a1a0f56cbef Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 21 Jun 2018 11:54:44 +1000 Subject: [PATCH 3/7] README: re-word top pre-amble --- README.md | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 77b4455dd..606ded7de 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,32 @@ # BitcoinJS (bitcoinjs-lib) [![Build Status](https://travis-ci.org/bitcoinjs/bitcoinjs-lib.png?branch=master)](https://travis-ci.org/bitcoinjs/bitcoinjs-lib) [![NPM](https://img.shields.io/npm/v/bitcoinjs-lib.svg)](https://www.npmjs.org/package/bitcoinjs-lib) -[![tip for next commit](https://tip4commit.com/projects/735.svg)](http://tip4commit.com/projects/735) [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) -The pure JavaScript Bitcoin library for node.js and browsers. -Estimated to be in use by over 15 million wallet users and is the backbone for almost all Bitcoin web wallets in production today. - - -## Features -- Clean: Pure JavaScript, concise code, easy to read. -- Tested: Coverage > 90%, third-party integration tests. -- Careful: Two person approval process for small, focused pull requests. -- Compatible: Works on Node.js and all modern browsers. -- Powerful: Support for advanced features, such as multi-sig, HD Wallets. -- Secure: Strong random number generation, PGP signed releases, trusted developers. -- Principled: No support for browsers with crap RNG (IE < 11) -- Standardized: Node community coding style, Browserify, Node's stdlib and Buffers. -- Fast: Optimized code, uses typed arrays instead of byte arrays for performance. -- Experiment-friendly: Bitcoin Mainnet and Testnet support. -- Altcoin-ready: Capable of working with bitcoin-derived cryptocurrencies (such as Dogecoin). +A javascript Bitcoin library for node.js and browsers. +Released under the terms of the [MIT LICENSE](LICENSE). ## Should I use this in production? -If you are thinking of using the master branch of this library in production, **stop**. +If you are thinking of using the *master* branch of this library in production, **stop**. Master is not stable; it is our development branch, and [only tagged releases may be classified as stable](https://github.com/bitcoinjs/bitcoinjs-lib/tags). +## Can I trust this code? +> Don't trust. Verify. + +We recommend every user of this library and the [bitcoinjs](https://github.com/bitcoinjs) ecosystem to audit and verify any underlying code for its validity and suitability. + +Mistakes and bugs happen, but with your help in resolving and reporting [issues](https://github.com/bitcoinjs/bitcoinjs-lib/issues), together we can produce open source software library that is: + +- Easy to audit and verify, +- Tested, with test coverage >90%, +- Advanced and feature rich, +- Standardized, using [standard](http://github.com/standard/standard) and Node `Buffer`'s throughout, and +- Friendly, with a strong and helpful community, ready to answer questions. + + ## Installation ``` bash npm install bitcoinjs-lib From a85bea5a895f7cfabcd6c45559bd1ade1e903b39 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 21 Jun 2018 12:06:14 +1000 Subject: [PATCH 4/7] README: add Node LTS version hint, and warning about npm --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 606ded7de..dc8fa0a69 100644 --- a/README.md +++ b/README.md @@ -18,24 +18,29 @@ Master is not stable; it is our development branch, and [only tagged releases ma We recommend every user of this library and the [bitcoinjs](https://github.com/bitcoinjs) ecosystem to audit and verify any underlying code for its validity and suitability. -Mistakes and bugs happen, but with your help in resolving and reporting [issues](https://github.com/bitcoinjs/bitcoinjs-lib/issues), together we can produce open source software library that is: +Mistakes and bugs happen, but with your help in resolving and reporting [issues](https://github.com/bitcoinjs/bitcoinjs-lib/issues), together we can produce open source software that is: - Easy to audit and verify, -- Tested, with test coverage >90%, +- Tested, with test coverage >95%, - Advanced and feature rich, - Standardized, using [standard](http://github.com/standard/standard) and Node `Buffer`'s throughout, and - Friendly, with a strong and helpful community, ready to answer questions. - ## Installation ``` bash npm install bitcoinjs-lib ``` +Typically we support the [Node Maintenance LTS version](https://github.com/nodejs/Release). +If in doubt, see the [.travis.yml](.travis.yml) for what versions are used by our continuous integration tests. + +**WARNING**: We presently don't provide any tooling to verify that the release on `npm` matches GitHub. As such, you should verify anything downloaded by `npm` against your own verified copy. + + ## Setup ### Node.js ``` javascript -var bitcoin = require('bitcoinjs-lib') +const bitcoin = require('bitcoinjs-lib') ``` ### Browser From 4838b6b3c26fa25c1c439505e5469290fdd469aa Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 21 Jun 2018 12:14:21 +1000 Subject: [PATCH 5/7] README: rm browserify tutorial, add typescript clarifications --- README.md | 58 +++++++++++-------------------------------------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index dc8fa0a69..fba551cd9 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Master is not stable; it is our development branch, and [only tagged releases ma We recommend every user of this library and the [bitcoinjs](https://github.com/bitcoinjs) ecosystem to audit and verify any underlying code for its validity and suitability. -Mistakes and bugs happen, but with your help in resolving and reporting [issues](https://github.com/bitcoinjs/bitcoinjs-lib/issues), together we can produce open source software that is: +Mistakes and bugs happen, but with your help in resolving and reporting [issues](https://github.com/bitcoinjs/bitcoinjs-lib/issues), together we can produce open source software that is: - Easy to audit and verify, - Tested, with test coverage >95%, @@ -32,68 +32,32 @@ npm install bitcoinjs-lib ``` Typically we support the [Node Maintenance LTS version](https://github.com/nodejs/Release). -If in doubt, see the [.travis.yml](.travis.yml) for what versions are used by our continuous integration tests. +If in doubt, see the [.travis.yml](.travis.yml) for what versions are used by our continuous integration tests. **WARNING**: We presently don't provide any tooling to verify that the release on `npm` matches GitHub. As such, you should verify anything downloaded by `npm` against your own verified copy. -## Setup -### Node.js -``` javascript -const bitcoin = require('bitcoinjs-lib') -``` +## Usage ### Browser -If you're familiar with how to use browserify, ignore this and proceed normally. -These steps are advisory only, and may not be suitable for your application. - -[Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps. - -For your project, create an `index.js` file -``` javascript -let bitcoin = require('bitcoinjs-lib') - -// your code here -function myFunction () { - return bitcoin.ECPair.makeRandom().toWIF() -} - -module.exports = { - myFunction -} -``` - -Now, to compile for the browser: -``` bash -browserify index.js --standalone foo > app.js -``` +The recommended method of using `bitcoinjs-lib` in your browser is through [Browserify](https://github.com/substack/node-browserify). +If you're familiar with how to use browserify, ignore this and carry on, otherwise, it is recommended to read the tutorial at http://browserify.org/. -You can now put `