3.7.22 • Published 5 years ago

blocktrail-sdk v3.7.22

Weekly downloads
809
License
MIT
Repository
github
Last release
5 years ago

BlockTrail NodeJS SDK

This is the BlockTrail NodeJS SDK. This SDK contains methods for easily interacting with the BlockTrail API. Below are examples to get you started. For additional examples, please see our official documentation at https://www.blocktrail.com/api/docs/lang/nodejs

Latest Stable Version Build Status Sauce Test Status

Sauce Test Status

The Blocktrail SDK is tested against;

  • NodeJS:
    • 0.11
    • 0.12
    • 5.11
    • 6.3.0
    • 7.1.0
  • Browser:
    • Google Chrome 48 / latest
    • Firefox 49 / latest
    • Safari 10.0 / latest
    • Edge 14.14393
    • IE 11.103
    • Android 4.4
    • Android 5.0
    • iPhone OS X 10.10

Upgrading from v3.x to v3.4.0

We've seperated out the backup PDF generator because it contained a lot of dependencies while barely anyone uses it.
If you do want to use it, see the blocktrail-sdk-backup-generator package.

Upgrading from v2.x to v3.0.0

IMPORTANT v3.0.0 introduces a new DEFAULT wallet encryption, please make sure you upgrade the SDK everywhere you're using it!!

Upgrading from v1.x to v2.0.0

IMPORTANT v2.0.0 has a few BC breaks, please check docs/CHANGELOG.md!!

IMPORTANT! FLOATS ARE EVIL!!

As is best practice with financial data, The API returns all values as an integer, the Bitcoin value in Satoshi's. In Javascript even more than in other languages it's really easy to make mistakes when converting from float to integer etc!

The BlockTrail SDK has some easy to use functions to do this for you, we recommend using these and we also strongly recommend doing all Bitcoin calculation and storing of data in integers and only convert to/from Bitcoin float values for displaying it to the user.

var blocktrail = require('blocktrail-sdk');

console.log("123456789 Satoshi to BTC: ", blocktrail.toBTC(123456789));
console.log("1.23456789 BTC to Satoshi: ", blocktrail.toSatoshi(1.23456789));

A bit more about this can be found in our documentation.

Installation

You can install the package through NPM (https://www.npmjs.org/package/blocktrail-sdk).

npm install blocktrail-sdk

Usage

Please visit our official documentation at https://www.blocktrail.com/api/docs/lang/nodejs for the usage.

Promises vs Callbacks

Personally we prefer good old callbacks over promises,
but to make everyone happy the SDK functions accept a callback argument and return a (Q)promise object, so you can use whatever you prefer!

Support and Feedback

Be sure to visit the BlockTrail API official documentation website for additional information about our API.

If you find a bug, please submit the issue in Github directly. BlockTrail-NodeJS-SDK Issues

As always, if you need additional assistance, drop us a note at support@blocktrail.com.

Unit Tests

Unit Tests are created with Mocha and can be ran with npm test (or mocha)

We also run jshint and jscs, these are automatically ran by travis-ci for every commit and pull request.

jshint main.js lib/ test/
jscs main.js lib/ test/

Browserify

The BlockTrail NodeJS SDK can be browserified to use it in the browser, which we use ourselves for wallet actions from our webapp.
If you want to test or develop on the SDK in the browser you can use grunt build (and grunt watch) to build the browserify version.

You need to pull the git submodules before you can build the browserify version:
git submodule update --init --recursive

Files in ./build are:

  • blocktrail-sdk.js (and blocktrail-sdk.min.js) the blocktrailSDK browserified
  • jsPDF.js (and jsPDF.min.js) dependancy for generating the backup PDF
  • blocktrail-sdk-full.js (and blocktrail-sdk-full.min.js) the blocktrailSDK browserified + jsPDF bundled

If you use these browserified versions of our SDK it will be accessible as window.blocktrailSDK or plain blocktrailSDK.

Known Supported and Tested Browsers:

  • Android 4.3+ (Use Crosswalk for lower versions if neccesary)
  • iOS6+
  • IE9+

For the following any modern version will work just fine:

  • Chrome
  • FireFox
  • Safari

Webworker

To defer encryption/decryption/keyderivation to webworkers in the browser it's neccesary to make create the following function in the global scope:

function onLoadWorkerLoadAsmCrypto(worker) {
    worker.postMessage({
        method: 'importScripts',
        script: document.location.protocol + '//' + document.location.host + '/build/asmcrypto.min.js'
    });
}

This will get called as the onLoad of the webworker and will trigger importing the asmcrypto.min.js.
We had to seperate asmcrypto.js from the main browserify bundle because uglify was killing the ASM.js.

Uglify

If you're planning to uglify/minify the javascript yourself, make sure to exclude the following variable names from being mangled:
['Buffer', 'BitInteger', 'Point', 'Script', 'ECPubKey', 'ECKey']

License

The BlockTrail NodeJS SDK is released under the terms of the MIT license. See LICENCE.md for more information or see http://opensource.org/licenses/MIT.

3.7.22

5 years ago

3.7.21

5 years ago

3.7.20

5 years ago

3.7.19

5 years ago

3.7.18

5 years ago

3.7.17

5 years ago

3.7.16

6 years ago

3.7.15

6 years ago

3.7.14

6 years ago

3.7.13

6 years ago

3.7.12

6 years ago

3.7.11

6 years ago

3.7.10

6 years ago

3.7.9

6 years ago

3.7.8

6 years ago

3.7.7

6 years ago

3.7.6

6 years ago

3.7.5

6 years ago

3.7.4

6 years ago

3.7.3

6 years ago

3.7.2

6 years ago

3.7.1

6 years ago

3.7.0

6 years ago

3.6.9

6 years ago

3.6.8

6 years ago

3.6.7

6 years ago

3.6.6

6 years ago

3.6.3

6 years ago

3.6.1

6 years ago

3.6.0

6 years ago

3.5.8

6 years ago

3.5.7

6 years ago

3.5.6

6 years ago

3.5.5

6 years ago

3.5.4

6 years ago

3.5.3

6 years ago

3.5.2

6 years ago

3.5.1

6 years ago

1.3.18

6 years ago

1.3.17

6 years ago

2.1.6

6 years ago

1.3.16

6 years ago

3.5.0

6 years ago

3.4.0

7 years ago

3.3.5

7 years ago

3.3.4

7 years ago

3.3.3

7 years ago

3.3.2

7 years ago

3.3.1

7 years ago

3.3.0

7 years ago

3.2.0

7 years ago

3.0.14

7 years ago

3.0.13

7 years ago

3.0.12

7 years ago

3.0.10

7 years ago

3.0.9

7 years ago

3.0.8

7 years ago

3.0.7

7 years ago

3.0.6

7 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.1.4

7 years ago

2.1.1

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.3.15

9 years ago

1.3.14

9 years ago

1.3.13

9 years ago

1.3.12

9 years ago

1.3.11

9 years ago

1.3.9

9 years ago

1.3.8

9 years ago

1.3.7

9 years ago

1.3.6

9 years ago

1.3.5

9 years ago

1.3.4

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0-15

9 years ago

1.3.0-14

9 years ago

1.3.0-13

9 years ago

1.3.0-12

9 years ago

1.3.0-11

9 years ago

1.3.0-10

9 years ago

1.3.0-9

9 years ago

1.3.0-8

9 years ago

1.3.0-7

9 years ago

1.3.0-6

9 years ago

1.3.0-5

9 years ago

1.3.0-4

9 years ago

1.3.0-3

9 years ago

1.3.0-2

9 years ago

1.3.0-1

9 years ago

1.3.0-0

9 years ago

1.2.6

9 years ago

1.2.5

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.3

9 years ago

1.1.0-beta4

9 years ago

1.1.0-beta3

9 years ago

1.1.0-beta2

9 years ago

1.1.0-beta

9 years ago

1.1.0-beta1

9 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.1.0

10 years ago