Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI & Publish

on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: "24.x"
# The lock is written by npm 12, which also runs install scripts only for packages the
# project approves (allowScripts).
- run: npm install -g npm@12.2.1
- run: npm ci
- run: npm test

publish:
needs: test
if: github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: "24.x"
registry-url: "https://registry.npmjs.org"
- run: npm install -g npm@12.2.1
- name: Set version from release tag
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
npm version "$VERSION" --no-git-tag-version --allow-same-version
- run: npm ci
- run: npm test
# The trusted publisher allows staging only: a maintainer approves each version on
# npmjs.com with 2FA before it is public.
- run: npm stage publish --provenance --access public
45 changes: 0 additions & 45 deletions .jshintrc

This file was deleted.

4 changes: 4 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recursive": true,
"timeout": 5000
}
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .zuul.yml

This file was deleted.

39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ Flux is a powerful new peer-to-peer platform for the next generation of financia

## Get Started

Requires Node.js 24 or newer.

```
npm install @runonflux/bitcore-lib
```

```javascript
const bitcore = require('@runonflux/bitcore-lib');
```

To work on the library itself:

```
git clone https://github.com/runonflux/bitcore-lib.git
cd bitcore-lib
npm install
npm test
```


Expand Down Expand Up @@ -44,18 +57,6 @@ We're using Bitcore in production, as are [many others](http://bitcore.io#projec

If you find a security issue, please email security@bitpay.com.

## Building the Browser Bundle

To build a bitcore-lib full bundle for the browser:

```sh
gulp browser
```

This will generate files named `bitcore-lib.js` and `bitcore-lib.min.js`.

You can also use our pre-generated files

## Development & Tests

```sh
Expand All @@ -64,14 +65,20 @@ cd bitcore-lib
npm install
```

Run all the tests:
Requires Node.js 24 or later. Run all the tests:

```sh
gulp test
npm test
```

You can also run just the Node.js tests with `gulp test:node`, just the browser tests with `gulp test:browser`
or create a test coverage report (you can open `coverage/lcov-report/index.html` to visualize it) with `gulp coverage`.
`npm test` runs every file under `test/` in its own mocha process and checks
each outcome against `test/inherited-failures.json`, the inherited upstream
tests that fail at runonflux/bitcore-lib 8f5453f. `test/differential.js`
checks this library against bitcore-lib 8f5453f, installed as the
devDependency `bitcore-lib-8f5453f`, on Flux mainnet blocks and transactions
(`test/data/flux-mainnet/corpus.json`, written by
`scripts/fetch-mainnet-corpus.js`), keys, addresses, HD keys and signatures.
A single file runs with `npx mocha test/<file>.js`.

## License

Expand Down
31 changes: 0 additions & 31 deletions bower.json

This file was deleted.

7 changes: 1 addition & 6 deletions docs/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ After this, you can include the bundled release versions in your HTML file:
<body>

<script type="text/javascript">
var bitcore = require('bitcore-lib');
var bitcore = require('@runonflux/bitcore-lib');
var Mnemonic = require('bitcore-mnemonic');
// etc...
</script>
Expand All @@ -59,8 +59,3 @@ browserify --require ./index.js:bitcore-lib | uglifyjs > bitcore-lib.min.js
```sh
browserify --require ./index.js:bitcore-mnemonic --external bitcore-lib | uglifyjs > bitcore-mnemonic.min.js
```

In many of the modules you can also run the command to build a browser bundle:
```sh
gulp browser
```
2 changes: 1 addition & 1 deletion docs/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var transaction = new Transaction()

## Example constructing transactions v4
```javascript
const bitcore = require('bitcore-lib')
const bitcore = require('@runonflux/bitcore-lib')
let transaction = new bitcore.Transaction()
transaction.version = 4
transaction.fOverwintered = true
Expand Down
5 changes: 0 additions & 5 deletions gulpfile.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bitcore.Unit = require('./lib/unit');
// dependencies, subject to change
bitcore.deps = {};
bitcore.deps.bnjs = require('bn.js');
bitcore.deps.bs58 = require('bs58');
bitcore.deps.bs58 = require('bs58').default;
bitcore.deps.Buffer = Buffer;
bitcore.deps.elliptic = require('elliptic');
bitcore.deps._ = require('lodash');
Expand Down
36 changes: 0 additions & 36 deletions karma.conf.js

This file was deleted.

6 changes: 3 additions & 3 deletions lib/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Address._transformObject = function(data) {
$.checkArgument(data.hash || data.hashBuffer, 'Must provide a `hash` or `hashBuffer` property');
$.checkArgument(data.type, 'Must provide a `type` property');
return {
hashBuffer: data.hash ? new Buffer(data.hash, 'hex') : data.hashBuffer,
hashBuffer: data.hash ? Buffer.from(data.hash, 'hex') : data.hashBuffer,
network: Networks.get(data.network) || Networks.defaultNetwork,
type: data.type
};
Expand Down Expand Up @@ -392,7 +392,7 @@ Address.fromObject = function fromObject(obj) {
JSUtil.isHexa(obj.hash),
'Unexpected hash property, "' + obj.hash + '", expected to be hex.'
);
var hashBuffer = new Buffer(obj.hash, 'hex');
var hashBuffer = Buffer.from(obj.hash, 'hex');
return new Address(hashBuffer, obj.network, obj.type);
};

Expand Down Expand Up @@ -460,7 +460,7 @@ Address.prototype.isPayToScriptHash = function() {
* @returns {Buffer} Bitcoin address buffer
*/
Address.prototype.toBuffer = function() {
var version = new Buffer(2);
var version = Buffer.alloc(2);
version.writeUInt16BE(this.network[this.type], 0);
var buf = Buffer.concat([version, this.hashBuffer]);
return buf;
Expand Down
8 changes: 4 additions & 4 deletions lib/block/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Block(arg) {
if (!(this instanceof Block)) {
return new Block(arg);
}
_.extend(this, Block._from(arg));
_.assign(this, Block._from(arg));
return this;
}

Expand Down Expand Up @@ -117,7 +117,7 @@ Block.fromBuffer = function fromBuffer(buf) {
* @returns {Block} - A hex encoded string of the block
*/
Block.fromString = function fromString(str) {
var buf = new Buffer(str, 'hex');
var buf = Buffer.from(str, 'hex');
return Block.fromBuffer(buf);
};

Expand All @@ -127,7 +127,7 @@ Block.fromString = function fromString(str) {
*/
Block.fromRawBlock = function fromRawBlock(data) {
if (!BufferUtil.isBuffer(data)) {
data = new Buffer(data, 'binary');
data = Buffer.from(data, 'binary');
}
var br = BufferReader(data);
br.pos = Block.Values.START_OF_BLOCK;
Expand Down Expand Up @@ -275,7 +275,7 @@ Block.prototype.inspect = function inspect() {

Block.Values = {
START_OF_BLOCK: 8, // Start of block in raw block data
NULL_HASH: new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
NULL_HASH: Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
};

module.exports = Block;
Loading
Loading