Giter Site home page Giter Site logo

bitcoin-com / bitbox-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bigearth/bitbox-cli

85.0 15.0 62.0 3.41 MB

BITBOX SDK for Bitcoin Cash

Home Page: https://developer.bitcoin.com/bitbox

License: MIT License

JavaScript 18.16% TypeScript 81.84%

bitbox-sdk's Introduction

BITBOX SDK

bitbox-sdk is a utility for creating great Bitcoin Cash applications. It can be used from the command line or from within client/server apps.

Extensive documentation available in the docs directory:

Open Source / Creative Commons Listings

Font awesome

Cube icon available under CC v4.0

bitbox-sdk's People

Contributors

alexdovzhanyn avatar amitrana007 avatar cgcardona avatar christroutner avatar cloneearth avatar crazymerlyn avatar cyio avatar fifikobayashi avatar haryu703 avatar jcramer avatar lightswarm124 avatar lpinca avatar missmonacoin avatar p0o avatar philipinho avatar porlybe avatar rcawston avatar rkalis avatar sagech avatar shilch avatar spendbch avatar spicypete avatar usatie avatar yuiki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitbox-sdk's Issues

Refactor Blockchain.getBlockHeader()

This Issue is tagged with a bounty of 0.4 BCH. Once a Pull Request (PR) has been verified to meet the acceptance criteria, and merged into the ct-v2-refactor branch, the funds will be released to the developer.

Overview

rest.bitcoin.com is a web service running as a REST API. It communicates with a Bitcoin Cash full node, Insight API, BitDB database, and a growing array of other bitcoin-focused databases. BITBOX JavaScript SDK is an npm library used by developers to leverage the rest.bitcoin.com web service. Learn More

rest.bitcoin.com is wrapping up a large refactor, referred to as V2. BITBOX SDK is currently being refactored to reflect the new endpoints. The scope of this Issue is to refactor the BITBOX Blockchain.getBlockHeader() endpoint to use the new GET and POST endpoints in rest.bitcoin.com.

This is the existing code that needs to be refactored

Before starting work on this Issue, it is advisable to add a comment to this issue with a link to your fork of the code base, so that others can follow the progress of your work. If work pauses for more than 48 hours, other developers are encouraged to pick up this Issue.

Questions or concerns about this Issue or bounty can be left in the comments of this Issue, or discussed on our developer Discord channel.

Notes

  • The code governing the control of the endpoint on the rest.bitcoin.com side can be viewed here.

  • The Address and Block endpoints have already been refactored in a manner similar to the specifications in this Issue. These endpoints can be used as an example of the code changes required by this Issue.

Specifications

The PR submitted to fulfill this Issue should have the following features:

  • The existing getBlockHeader() function needs to be refactored according to the following criteria:

    • An input string should trigger a GET call rest.bitcoin.com/v2/blockchain/getBlockHeader. The verbose query string should also be transmitted and appropriately control the output.

    • An input array of strings should trigger a POST call to rest.bitcoin.com/v2/blockchain/getBlockHeader. The verbose input should also be passed along as part of the body.

    • An input not matching either of the above conditions should throw an error.

  • Passing integration tests must be included to cover the above code changes. Here is an example of integration tests for similar code changes to the Address.details endpoint.

Acceptance Criteria

In order for a developer to receive the bounty attached to this issue, they must meet the following acceptance criteria:

  • A PR must be submitted to this repository with the code changes listed in the Specifications section.
  • All unit tests must pass.
  • All integration tests must pass.

Lock dependencies?

Given that bitbox is handling private keys, I think it might be a good idea to protect from dependency injection attacks like the one that hit copay.

BITBOX.Socket() stopped working

From Pa0ol:

BITBOX.Socket() stopped working sometime this week or so
i'm on "bitbox-sdk": "^3.0.9",and my socket code no longer gets any transactions or block information
pointing the resturl to v1 doesn't solve the problem

npm install for bitbox-sdk failed

Got this error and additional errors when trying to install the latest version on BITBOX SDK. The scope of this issue is to review the installation of BITBOX SDK and make sure it can install and run correctly.

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! path /home/trout/work/personal/koa-ipfs-blog/node_modules/bitbox-sdk/index.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/trout/work/personal/koa-ipfs-blog/node_modules/bitbox-sdk/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 
๐Ÿ“„ POST /-/npm/v1/security/audits/quick 200 1918ms

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/trout/.npm/_logs/2019-05-18T22_07_02_882Z-debug.log
๐ŸŽ /usr/bin/npm exited with code 254

Unable to get block hash by height

I get an error message in node that I'm unable to parse (HTML with an object in it) when I try this function, e.g. copy pasting the exact code at developer.bitcoin.com and trying to run in node:

(async () => {
  try {
    let getBlockHash = await BITBOX.Blockchain.getBlockHash([0]);
    console.log(getBlockHash);
  } catch(error) {
   console.error(error)
  }
})()

async getBlockHash(height = 1) {

I don't see the API endpoint referenced in this source code at rest.bitcoin.com

Manually attempting https://rest.bitcoin.com/blockchain/getblockhash/0 returns

[object Object]

in the browser

BITBOX.Socket - Problem

Hello!
I'am try to use https://developer.bitcoin.com/bitbox/docs/socket.html method for my balance refresh.
But almost all the time I get this error:

WebSocket connection to 'wss://rest.bitcoin.com/socket.io/?EIO=3&transport=websocket&sid=Qp14fOEUHEhSzc7EABVL' failed: Error during WebSocket handshake: Unexpected response code: 400

Request URL:wss://rest.bitcoin.com/socket.io/?EIO=3&transport=websocket&sid=KeBNoYd9ptCqZLABABVc
Request Method:GET
Status Code:400 Bad Request
Response Headers
view parsed
**HTTP/1.1 400 Bad Request**
Date: Mon, 17 Sep 2018 18:44:23 GMT
Content-Type: text/html
Content-Length: 18
Connection: keep-alive
Strict-Transport-Security: max-age=2592000; includeSubDomains
X-Content-Type-Options: nosniff
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 45bdb9508b4e8b88-KBP
Request Headers
view parsed
GET wss://rest.bitcoin.com/socket.io/?EIO=3&transport=websocket&sid=KeBNoYd9ptCqZLABABVc HTTP/1.1
Host: rest.bitcoin.com
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: http://localhost:9080
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Electron/2.0.8 Safari/537.36
Accept-Encoding: gzip, deflate
Accept-Language: en-US
Cookie: __cfduid=d4bcbe8959108c89e2c0733dcc0075e231536849438
Sec-WebSocket-Key: 3Thb36WPdbQZVxnt4QQYUg==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Query String Parameters
view source
view URL encoded
EIO:3
transport:websocket
sid:KeBNoYd9ptCqZLABABVc

But sometimes I get a correct connection

Request URL:wss://rest.bitcoin.com/socket.io/?EIO=3&transport=websocket&sid=SOslMz9p1Bch5shgAB_t
Request Method:GET
**Status Code:101 Switching Protocols**
Response Headers
view parsed
HTTP/1.1 101 Switching Protocols
Date: Mon, 17 Sep 2018 18:34:13 GMT
Connection: upgrade
Upgrade: websocket
Sec-WebSocket-Accept: ce151lk6c3DmV60KEu8+McMG9PI=
Sec-WebSocket-Extensions: permessage-deflate
Strict-Transport-Security: max-age=2592000; includeSubDomains
X-Content-Type-Options: nosniff
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 45bdaa66edb18b28-KBP
Request Headers
view parsed
GET wss://rest.bitcoin.com/socket.io/?EIO=3&transport=websocket&sid=SOslMz9p1Bch5shgAB_t HTTP/1.1
Host: rest.bitcoin.com
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: http://localhost:9080
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Electron/2.0.8 Safari/537.36
Accept-Encoding: gzip, deflate
Accept-Language: en-US
Cookie: __cfduid=d4bcbe8959108c89e2c0733dcc0075e231536849438
Sec-WebSocket-Key: CcSJjOCMFEwg0lb4uoG/yA==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Query String Parameters
view parsed
EIO=3&transport=websocket&sid=SOslMz9p1Bch5shgAB_t

Discuss Crypto Library Usage

This issue is intended to foster discussion on different crypto libraries used. The pros and cons of working with each one.

Three popular crypto libraries are scrypt, bcrypt, and bcryptjs. bcrypt is a binary blob, compiled and included as a dependency. As a result, it breaks between versions of nodejs because it must be compiled for a specific version. bcryptjs is a javascript native, drop-in replacement for bcrypt.

BITBOX apparently uses scrypt, and this message popped up in the Discord chatroom:

Got this error.The package at "node_modules/scryptsy/lib/scrypt.js" attempted to import the Node standard library module "crypto".It failed because React Native does not include the Node standard library.

Possibility of moving to a non-forked repo?

Github does not provide search in the codebase of forked repositories so anyone who likes to search something in the code should clone it. Since this repo is supposed to be maintained for a long time can you consider moving to an original repo and just credit the developer who made it in the first place in Readme?

Create example for decoding and transmitting memo.cash messages

The scope of this Issue is to add two new example apps to the examples directory. One to read memo.cash messages from a transaction, and one send a memo.cash message. I've already created both apps in other projects, I just need to port the code over to this repo.

Suggestion: API Needs to be searchable and navigation improved

Right now, when one goes to the BITBOX SDK doc page it is impossible to search the SDK and know what functions exist or not. For instance, I needed to access some base58 encoding and could not figure out whether that was easily accessible in the SDK.
Having a search function for it is key for productivity.
In addition, also to improve visibility on the SDK, we need to add a tree view that opens up when someone selects one of the main topics on the left. For instance, if I click on Address, it should show the list of all functions available under that object instead of me having to scroll down to see what is in there and possibly missing one. This would improve navigation tremendously.

New function: Add direct access to Private Key for HDNode

Premises:
Some people will use simple private key and public key for single uses where they don't need a HD wallet, be it from another platform or language (so not directly from HDNode). These people may want to use the BITBOX SDK for some of it useful functionality but already have their simple private key created somewhere else.

Right now, there is no direct way to import such private key and one has to first convert it to the WIF format before importing it into the HDNode object.
It would be useful (I had that need coming from Django in Python with private keys in a DB) to be able to directly import a private key into an HDNode object using for instance HDNode.fromPriv and then HDNode.toPriv to extract one. This would increase productivity for many people.
In my opinion, an SDK is about providing the exact function people need without them having to start doing research and then transformations to adapt to the SDK functionality. Thanks guys!

BITBOX.Script.classifyOutput() produces Error: Expected Hex, got String

let nullDataOutput = "OP_RETURN 877 8106baaeb4f1b3f7f2558b788be6cb62d76b5ea8eba64a05a509edd504d76fb7 f09fa496203120424348203d203536312e30322420f09f938820362e3533250a54697073203d206675656cefb88f";
let result = BITBOX.Script.classifyOutput(BITBOX.Script.fromASM(nullDataOutput));
console.log(result);

This block of code produces Error: Expected Hex, got String "877".

This OP_RETURN is from https://rest.bitcoin.com/v1/transaction/details/c4e93088b8658b9a02e52171b324512737e4ad9c7fb402ca6b9af1d8f9f038d8 output n=1

Price library is not working

Trying to use the BITBOX.Price library returns a bunch of errors and HTML.

Here is an example node.js application to reproduce this issue:

const BITBOXSDK = require('bitbox-sdk')
const BITBOX = new BITBOXSDK()

async function myfunc() {
  try {
    let current = await BITBOX.Price.current();
    console.log(current);
  } catch(error) {
   console.error(error)
  }
}
myfunc()

This is based on the BITBOX documentation:
https://developer.bitcoin.com/bitbox/docs/price

TransactionInput and AddressUtxoResult incompatible

The docs show the following code:

const utxo = await this.bitbox.Address.utxo([sourceAddress]);
const rawTx = await this.wormhole.RawTransactions.create([utxo[0][0]], {});

however, with typescript it does not work because TransactionInput and AddressUtxoResult are different types. Probably TransactionInput should implement (or inherit from) AddressUtxoResult.

Regardless, how am I supposed to proceed here (i.e. how am I meant to be turning an AddressUtxoResult to TransactionInput. I can't even find a method to construct TransactionInput in the docs...

Is there a simple javascript library download available?

Hi @cgcardona today I tried to use BITBOX sdk!

BITBOX with --scaffold vue would work fine on my local machine, but apparently my webhost doesnt support it. I did run "node build/build.js", because "npm build" didnt work as there was a missing build script.

Then I copied the content from the "dist" folder to the webserver and it didnt show anything but the title.

After that I tried a totally different approach and now I use https://github.com/unwriter/datacash, because these libs are available as javascript files without any requirement of Node.js on the server side.

Is there any way to integrate bitbox with a plain java script all-in-one file? Just like using datacash?
<script src='https://unpkg.com/datacash'></script>

Would be fantastic if I could use BITBOX asap! Thanks for providing a documented API!

Use less dependencies

Currently BITBOX uses 265(!) dependencies. Each of which can have own vulnerabilities, hacks, etc.. Frankly, for code that handles private keys - it's scary.

The worst offenders currently are:

browserify loads 135 deps! http://npm.broofa.com/[email protected]

qrcode loads 54 dependencies http://npm.broofa.com/[email protected]

socket.io loads 36 deps http://npm.broofa.com/[email protected]

Would it be possible to maybe replace those with some relevant code instead of using the whole package with all the dep graph?

Thanks!

Question: How to get a balance of already created wallet

Hello!

I'm trying to get balance for already created wallet which was create through Bitcoin.Com Wallet (https://wallet.bitcoin.com/). For testnet all works perfectly but for mainnet it's not working.
I'm use this code from docs

const BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default;
let BITBOX = new BITBOXCli();
let mnemonic = 'MY MAINNET MNEMONIC';
let rootSeed = BITBOX.Mnemonic.toSeed(mnemonic);
let masterHDNode = BITBOX.HDNode.fromSeed(rootSeed, 'bitcoincash');
let account = BITBOX.HDNode.derivePath(masterHDNode, "m/44'/145'/0'");
let change = BITBOX.HDNode.derivePath(account, "0/0");
let cashAddress = BITBOX.HDNode.toCashAddress(change);

let details = BITBOX.Address.details(this.cashAddress).then((result) => {
   console.log(result);
}, (err) => {
   console.log(err);
});

And I got an empty balance.. Seems it's some problem with keys.
Could you please tell is there any ability to get details and UTXO for already created wallet?

For test net I use path like this and its works

let account = BITBOX.HDNode.derivePath(masterHDNode, "m/44'/1'/0'")
let change = BITBOX.HDNode.derivePath(account, '0/0')

I'm also try to use "m/44'/0'/0'" for mainnet but result is the same.

Wallet Derivation

Different wallets use different HD derivation paths. There has been some confusion as to what derivation BITBOX uses and what other wallets use. This is the place to discuss what derivation paths to use and where to use them.

BITBOX examples use the "m/44'/145'/0'" derivation, but any derivation path can be used with the the masterHDNode.derivePath call. You can generate an output like the below by running this create-wallet example.

BIP44 Account: "m/44'/145'/0'"
m/44'/145'/0'/0/0: bitcoincash:qqvhu2v2lse0xq58jenwap9c2cxnxq7grv5xts4uc5
m/44'/145'/0'/0/1: bitcoincash:qp0w3ur8679t6uygkssn8jmvsm63jdzka5rypmj0tr
m/44'/145'/0'/0/2: bitcoincash:qzgnjhq9hh97at0z7u0g7qq0evsutauy5y9xpvrug5
m/44'/145'/0'/0/3: bitcoincash:qpq6zhhr5jaj6kemt8mkh4uadeyscp6l8q8zhlhheh
m/44'/145'/0'/0/4: bitcoincash:qr8vqugsytcczfxglhthwfv7znkvwzxv3ufs7sfmhj
m/44'/145'/0'/0/5: bitcoincash:qrx65g8rm2lanvjtm69fgk0um926q6n6jus9xlkrvt
m/44'/145'/0'/0/6: bitcoincash:qptupdrmrdp9y9k6mqdydyxkx0ffejsdp5x7kcjsej
m/44'/145'/0'/0/7: bitcoincash:qr2teks3lkgu96f6jgw0gnf86987lfpswy9ue2fd02
m/44'/145'/0'/0/8: bitcoincash:qq7zjhptdk4847l36aypdaa57sks5wd26yflw66tsc
m/44'/145'/0'/0/9: bitcoincash:qrzf7y6agjzzrs2c6drdf755v7j57ygagg2axzuyw2

BITBOX --scaffold didnt work out for me

I tried to install BITBOX with scaffold, I tried Vue which would run fine in development mode: npm run dev

But then when i tried to build things i got errors:

  1. npm run build wouldnt work as it says there is a build script missing
  2. So i did some research and found out that I can run node build\build.js
  3. I did then deploy that build to firebase but it gives me a blank screen: https://bitboxvue.firebaseapp.com/

2018-10-09T18_58_44_337Z-debug.log
2018-10-09T18_58_49_782Z-debug.log

I dont know why but the critical information is not included in the logs, so here that might help you:

C:\Users\root\Documents\GitHub\vuefire\firetestagain>npm install --save bitbox-cli
npm WARN deprecated [email protected]: ? Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to upda
te!

[email protected] install C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\keccak
npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."

[email protected] rebuild C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\keccak
node-gyp rebuild

C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\keccak>if not defined npm_config_node_gyp (node "C:\Users\root\AppData\Roaming\npm\n
ode_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\root\AppData\Roa
ming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\root\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_in
fo[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:276:12)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:336:11)
gyp ERR! stack at emitOne (events.js:116:13)
gyp ERR! stack at Socket.emit (events.js:211:7)
gyp ERR! stack at Pipe._handle.close [as _onclose] (net.js:561:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\root\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-g
yp.js" "rebuild"
gyp ERR! cwd C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\keccak
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\root\AppData\Roaming\npm-cache_logs\2018-10-09T18_58_44_337Z-debug.log
"Keccak bindings compilation fail. Pure JS implementation will be used."

[email protected] install C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\secp256k1
npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."

[email protected] rebuild C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\secp256k1
node-gyp rebuild

C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\secp256k1>if not defined npm_config_node_gyp (node "C:\Users\root\AppData\Roaming\np
m\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\root\AppData
Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\root\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_in
fo[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:276:12)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:336:11)
gyp ERR! stack at emitOne (events.js:116:13)
gyp ERR! stack at Socket.emit (events.js:211:7)
gyp ERR! stack at Pipe._handle.close [as _onclose] (net.js:561:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\root\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-g
yp.js" "rebuild"
gyp ERR! cwd C:\Users\root\Documents\GitHub\vuefire\firetestagain\node_modules\secp256k1
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\root\AppData\Roaming\npm-cache_logs\2018-10-09T18_58_49_782Z-debug.log
"Secp256k1 bindings compilation fail. Pure JS implementation will be used."
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","ar
ch":"x64"})

I also tried to run 'npm run build' on the AngularScaffold which led to this error:

C:\Users\root\Documents\GitHub\bitbox\TarifaCashAngular>npm run build

[email protected] build C:\Users\root\Documents\GitHub\bitbox\TarifaCashAngular
ng build --prod

Date: 2018-10-09T18:38:16.519Z
Hash: 057306fe7af8f27963f9
Time: 16720ms
chunk {0} styles.ac89bfdd6de82636b768.bundle.css (styles) 0 bytes [initial] [rendered]
chunk {1} polyfills.997d8cc03812de50ae67.bundle.js (polyfills) 84 bytes [initial] [rendered]
chunk {2} main.ee32620ecd1edff94184.bundle.js (main) 84 bytes [initial] [rendered]
chunk {3} inline.318b50c57b4eba3d437b.bundle.js (inline) 796 bytes [entry] [rendered]

ERROR in src/app/app.component.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import

  • as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: ng build --prod
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\root\AppData\Roaming\npm-cache_logs\2018-10-09T18_38_16_673Z-debug.log

In the end I am able to use BITBOX without scaffold so things are fine for me, but I guess for a newbie that might lead to frustration and maybe you can fix that issue?

BIP47 Integration

Creating this Issue to create a place to discuss BIP47 integration into BITBOX. What is it? What will it take to integrate it?

Some good reference information:

Perhaps a good place to start this conversation is to discuss the different between BIP47 and stealth addresses.

Please add your questions, links, and comments below.

BITBOX.Socket throws CORS errors in React scaffold

The scope of this issue is to get to the bottom of why the BITBOX socket class throws CORS errors and how it can be fixed.

Steps to Reproduce:

  1. Install a blank project using the react scaffold as illustrated here:
  • bitbox new hello-test -s react
  1. Add the scaffold example code to the top of the componentDidMount() function:
    let socket = new BITBOX.Socket({
      callback: () => {
        console.log('websocket is connected')
      }, restURL: 'https://rest.bitcoin.com'})


    socket.listen('transactions', (message) => {
      console.log(message)
    })

You can see the full code here.

  1. Run the scaffold project with npm start. It should launch the web browser with the react app. Open the console log and read the console. You should see the following:

screenshot

Interestingly, if you wait a few seconds, transaction data should start coming through and showing up in the console log. But the CORS errors will continue to be repeated every few seconds too.

Problem while requesting balance

I am using REST services and while requesting the balance, it returns 0 but the balance of my account is not 0.

please help.

I am using /address/details url.

Please add an index.d.ts to the project

I can't figure out how to use this project with typescript. Visual Studio Code does not sense the typings since there is no module declaration typings file.

Thanks.

Using the SDK with bitbox-gui

Hello,

I'm using the default scaffolding project for NodeJS trying to use the SDK with bitbox-gui. I'm declaring BITBOX as such:


let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default;
let BITBOX = new BITBOXCli({
  protocol: "http",
  host: "localhost",
  port: "8332",
  username: "",
  password: ""
});

It doesn't seem that the SDK is using my local node. I'm basing this on calling

BITBOX.Address.details

with my coinbase address. It always resolves with a balance of 0 regardless if I am running the bitbox-gui or not. Am I thinking about this wrong? Appreciate the work you guys / gals have done.

Possible errors with regtest / testnet WIF encodings

While going through the documentation & source code to add the regtest flag to the documentation where appropriate, I noticed two possible WIF encoding errors with regtest and testnet.

I can probably pick this up later if there's a resolution, but someone else can do so as well.

Referencing error for BITBOX.Address.details()

Bitbox-cli is occasionally throwing inside of the Address.details method. While that error is caught in the .catch, it throws again (uncaught) because it attempts to reference a missing property on the callback parameter. Below is the exact error message where I first noticed it. It doesn't do it consistently but I did manage to force it using the code at the bottom.

Since the same method is used to catch other errors throughout the library, it's possible this problem is occurring for other methods as well. I'll update if I find more.

Failed to fetch addressDetails for [ 'bitcoincash:qpc2hxhqllxhfyv7hv5u2zytsf52v2s9nv2p597vxw' ] : TypeError: Cannot read property 'message' of undefined
at /app/node_modules/bitbox-cli/lib/Address.js:155:57
at <anonymous>
2018-07-30T09:55:31.023741+00:00 app[worker.1]: at process._tickCallback (internal/process/next_tick.js:188:7)

You can force it by including an undefined element in the address array.

let oneOrMoreCashAddresses = [ 'bitcoincash:qpc2hxhqllxhfyv7hv5u2zytsf52v2s9nv2p597vxw', undefined];

BITBOX
.Address
.details(oneOrMoreCashAddresses)
.catch(console.log)
.then(function(addressDetails) {
  console.log(addressDetails);
});

Add OP_RETURN example

Users have requested that we add a code examples to the examples directory that shows how to send out an OP_RETURN code that can be read via memo.cash.

Testnet Faucet Broken After Fork

Leaving this here as a reminder to myself when I get back to work:

DevalboYesterday at 3:47 PM
I don't know if this is the right place, but I'm getting an error when I try to get some BCH from the testnet faucet at https://developer.bitcoin.com/faucets/bch/ - I can't reproduce the error because I'm limited to one request a day, but I remember seeing a message that the request was successful, but on the line below it, it said something like TXID: Invalid inputs

chris.troutnerYesterday at 7:49 PM
Thanks for the heads up @devalbo. I just tried it, and yep. I get the error Missing Inputs. I'll have to look into what is causing that error. Probably blowback from the fork or upgrades to new nodes.

Port Wormhole Examples to BITBOX

There are several examples in the Wormhole SDK that need to be ported over to BITBOX examples directory.

This would also be a good opportunity to go through all the existing examples and update them to use the new version of BITBOX and rest.

Please add additional examples in the comments that you'd like to see added to the BITBOX examples folder.

Add Base58 Encoding/Decoding functions to the SDK

Under the BITBOX.Util, we should add base58Encoding and base58Decoding. I understand it is readily available with the bs58 library but in order to make this SDK more user-friendly and accessible to the masses, we need to add simple utility functions that they are bound to use like the base58 ones.

Question about 256: absurdly-high-fee

Hello! First of all thx for your work!

I have an error 256: absurdly-high-fee when I send not all transaction amount to another wallet.

For example I have a test address bchtest:qp4xte74xs7xyt9d6njz9j299ctyqk0xtvd3qkrykv UTXO for it is

amount: 2.59979565
cashAddress: "bchtest:qp4xte74xs7xyt9d6njz9j299ctyqk0xtvd3qkrykv"
confirmations: 141
height: 1252157
legacyAddress: "mqDXzuumTK9f2cc16v7jHEV3HhQxV7vdhJ"
satoshis: 259979565
scriptPubKey: "76a9146a65e7d5343c622cadd4e422c9452e164059e65b88ac"
txid: "e641caf50a6f0791d5d0322f3caf2aac62e9ff52d65c4063fc833d08484346b1"
vout: 1

I'am using testnet and I try to send 5800 satoshi to another wallet bchtest:qrhf7n4nqz6k44lhyyv6lzwq50e9up2ujue2kgfpc2.

let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default
let BITBOX = new BITBOXCli({ restURL: 'https://trest.bitcoin.com/v1/' })

const mnemonic = 'my mnemonic' // I can provide it if you needed 

let rootSeed = BITBOX.Mnemonic.toSeed(mnemonic)
let masterHDNode = BITBOX.HDNode.fromSeed(rootSeed, 'testnet')
let account = BITBOX.HDNode.derivePath(masterHDNode, "m/44'/1'/0'")
let change = BITBOX.HDNode.derivePath(account, '0/0')

let cashAddress = 'qp4xte74xs7xyt9d6njz9j299ctyqk0xtvd3qkrykv'

let transactionBuilder = new BITBOX.TransactionBuilder('testnet')
let originalAmount = 5800
let vout = 1
let txid = 'e641caf50a6f0791d5d0322f3caf2aac62e9ff52d65c4063fc833d08484346b1'
transactionBuilder.addInput(txid, vout)

let byteCount = BITBOX.BitcoinCash.getByteCount({P2PKH: 1}, {P2PKH: 1})
let sendAmount = originalAmount - byteCount
transactionBuilder.addOutput('qrhf7n4nqz6k44lhyyv6lzwq50e9up2ujue2kgfpc2', sendAmount)

let keyPair = BITBOX.HDNode.toKeyPair(change)
let redeemScript
transactionBuilder.sign(0, keyPair, redeemScript, transactionBuilder.hashTypes.SIGHASH_ALL, originalAmount)

let tx = transactionBuilder.build()
let hex = tx.toHex()

BITBOX.RawTransactions.sendRawTransaction(hex, true).then((result) => { console.log('Success:', result) }, (err) => { console.log('Error', err) })

Transaction HEX is

0200000001b1464348083d83fc63405cd652ffe962ac2aaf3c2f32d0d591076f0af5ca41e6010000006a473044022038ea20126ae3292cb0216a44692206b4fa3bbd60a288c0952dcabab99c26f399022034b0149c5ae7ff8ccfab26a4404a8c91173426c0ac5d27fa3190e2990e5d67a74121025ba60c1ea64f64e2c5564e6e9872d8e2a4f549a07d205cb6650f175eef2c0cfeffffffff0194160000000000001976a914ee9f4eb300b56ad7f72119af89c0a3f25e055c9788ac00000000

And I get an error 256: absurdly-high-fee.
Seem it try to send all amount of the transaction and that's why I get this error. If I send all amount to another wallet all works perfect.

Could you please tell me what I'm doing wrong?

CoinJoin Implementation

As a user of Bitcoin Cash, I would like to engage in private transactions using CoinJoin or some other privacy enabling protocol.

The scope of this issue is to implement CoinJoin or an algorithm like it into BITBOX. This is also an opportunity to open up a conversation about transaction privacy and ways to implement it in Bitcoin Cash and BITBOX.

Reference

The original CoinJoin post:
https://bitcointalk.org/index.php?topic=279249

Two BTC wallets that implement CoinJoin:

bitbox.Transaction.details() does not throw errors

I'd expect that if an error happens, it is thrown so it can be caught in the catch block. It took us some time at Honest.Cash to figure out that the Transaction.details() returns errors as a successful data.

Example

This code requests details of 50 transactions:
bildschirmfoto 2019-03-04 um 15 00 14

The details method returns successfully but the returned data is:
{ error: 'Array too large. Max 20 txids' }

Statically we would expect an array or an thrown error.

Add Address.orderTransactions function

The Bitcore Insight API tx/?:address and /addr/:address will return a list of transactions associated with an address, but it makes no guarentee that the last (or first) transaction in the returned array will be the most recent transaction.

I created the library below to retrieve the transactions associated with an address. It then returns an array of objects, containing TXIDs and confirmations, ordered by confirmation.

https://github.com/christroutner/token-liquidity/blob/master/lib/last-transaction.js

The code from this library should be incorporated into the Address endpoint of BITBOX.

Create Example Oracle

From James Cramer:
has anyone created a simple oracle server using node.js for the purpose of getting signatures for op_checkdatasig?

was thinking:

  1. A simple node.js server
  2. have a simple oracle API with like 2 endpoints GET /info from oracle and POST /sign request to oracle server
  3. example could have instructions how to very quickly standup the server using heroku

the /sign endpoint would just need a json object including:
a) pubkey indicating which key used to sign
b) the message to be signed
c) optional: requester's pubkey and signature for auth purposes

the /info endpoint would just return some text about what the oracle's purpose is and what messages it will sign


It would be great to create some oracle example code that fits the specs above and add it to the example directory.

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.