Giter Club home page Giter Club logo

node-bitpay-client's Introduction

This repository is no longer maintained and it is being deprecated, please refer to the latest version Here

node-bitpay-client's People

Contributors

dependabot[bot] avatar gabegattis avatar gasteve avatar gordonwritescode avatar imrehg avatar kleetus avatar martindale avatar pnagurny avatar thejoshualewis avatar unusualbob 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  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  avatar  avatar  avatar  avatar  avatar  avatar

node-bitpay-client's Issues

required email param guidance

When using

$ bitpay login

The error message is received:
"Error: You must supply your BitPay email address"

Would be helpful to include the format to include it, as well as in the documentation examples, could read as:

"Error: You must supply your BitPay email address: --email [email protected]"

unit tests that pass

Let's rework the whole test suite here. I'd rather see very thorough unit tests for the library's innards than integration tests for our API here - I those belong in BitPay core.

trim, clean, and fix examples

A lot of the examples are broken and truthfully there are too many. Let's focus on examples for primary use cases, fix the ones we wish to keep, and lose the rest.

The 'nonce' parameter is fundamentally broken

The nonce parameter is required to increase monotonically. This may work well in single-process apps, but is a broken approach in modern distributed apps.

E.g. node-bitpay-client uses the current time to seed the nonce. This causes failed API requests when several processes are started.

Not able to get a pairing code

root@ubuntu:/home/ubuntu/node_modules/bitpay-rest/bin# ./bitpay.js pair
Do you have a pairing code?

Do you have a pairing code?(yes or no) no
Okay, we can get a pairing code, please choose a facade:
  1) Point of Sale
  2) Merchant
  : 1
Error: { Error: ETIMEDOUT
    at Timeout._onTimeout (/home/ubuntu/node_modules/request/request.js:846:19)
    at ontimeout (timers.js:482:11)
    at tryOnTimeout (timers.js:317:5)
    at Timer.listOnTimeout (timers.js:277:5) code: 'ETIMEDOUT', connect: true }
root@ubuntu:/home/ubuntu/node_modules/bitpay-rest/bin#

Double Enter on Command Line Utility

When running commands such as $ bitpay pair, it's nessassary to press enter twice for responses. There is a problem with prompt which needs to be fixed or find an alternative that works correctly.

[ISSUE] Error while npm install on Mac

Hi ,
I am unable to install bitpay-rest on my mac. "npm install bitpay-rest" is throwing an error when building secp256k1.
Have a look on logs

Afraz-imac:api ahmad.afraz$ cd /Users/ahmad.afraz/Desktop/btpay_poc
Afraz-imac:btpay_poc ahmad.afraz$ npm install bitpay-rest
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142

[email protected] install /Users/ahmad.afraz/Desktop/btpay_poc/node_modules/bignum
node-gyp rebuild

CXX(target) Release/obj.target/bignum/bignum.o
SOLINK_MODULE(target) Release/bignum.node

[email protected] install /Users/ahmad.afraz/Desktop/btpay_poc/node_modules/secp256k1
node-gyp rebuild

CXX(target) Release/obj.target/secp256k1/functions.o
In file included from ../functions.cc:5:
.././async.h:45:15: warning: 'Call' is deprecated [-Wdeprecated-declarations]
callback->Call(3, argv);
^
Please if someone encountered this issue and solved then tell me the solution. Thanks.

Pairing is broken

At the command line when typing

~$ bitpay pair

I get the error code "Label is invalid". Could be hostname has a period?

Authentication fail with client

Hey guys, having trouble to auth to test network here, tried the whole setup twice and saw the api docs

After trying a few options, I've installed with npm install -g bitpay
which bitpay resolves to /Users/flockonus/.nvm/v0.10.25/bin/bitpay which looks right because I use nvm which has never been a problem.

Ran bitpay keygen which worked, I opened the link in my browser and added the key. A problem here is that I'd expect this to be all i'd such as in ssh

Running bitpay pair gives me no hint of what to do.
While generating a new pair from the website, it doesn't help me make sense of what's going on either. It seems both the website and the client are looking for a code

$ bitpay whoami
Enter Key Password: 
Error: ID not associated with a BitPay user

I created a token from https://test.bitpay.com/api-tokens which was default to "Point-of-Sale" and used that token to sync the client, altho it seemed to have worked, the next steps didn't, neither trying to write an invoice from a script

$ bitpay pair -c znynVWs
Device paired!
$ bitpay whoami
Enter Key Password: 
Error: ID not associated with a BitPay user

ls ~/.bitpay
api.key     api.pub     config.json presets

Bitcoin address not available, try again later

I am using this module within MeteorJS, deployed in Docker. I have created a key pair and generated config. Copied the latter to the home dir of my Docker image and have also enforced config on the client

client = bitpay.createClient privKey, {
      config: {
        apiHost: 'bitpay.com',
        apiPort: 443,
        forceSSL: true
      }
    }

I consistently get a response - error: 'Bitcoin address not available, try again later' } when attempting to create invoices. When I try with the cli, there is no issue.

'Invalid signature' response when calling GET /tokens

I'm attempting to follow the installation instructions, I can generate a keypair and pair with the server correctly, however when I attempt to make the first request using:

./node_modules/bitpay-rest/bin/bitpay.js request -T merchant -X post -R invoices -P '{"price": 1, "currency": "USD"}'

I receive:

Error: { error: 'Invalid signature' }

I get the same error when calling from the CLI, or when copying and pasting the code in the 'module' section of the readme.

Doing some debugging I can see that the error response is coming from calling GET: https://test.bitpay.com:443/tokens and the string being signed is simply: https://test.bitpay.com:443/tokens

I'm unsure how to debug this further. This is from a clean install, copying and pasting instructions from the readme.

NPM install does not work

The npm install bitpay command given in the Readme is actually trying to install another library. Or is that the same just the link wasn't updated? Hard to tell, but either way, no actual code is installed by npm.

Can't log in correctly to access non-public methods

When I use the default bitpay login -e <myemail> method, I get this message during the authorization:

No private key specified. Only public methods allowed.

Afterwards, if I for example want to create bills, naturally I get this error message:

{ error: 'You do not have access to this resource. (user)' }

On the other hand, I can't seem to find an example for logging in to access the merchant functions. If I modify the login action similarly as e.g. I see in the examples/create-bill.js, along the lines of

var encPrivkey = fs.readFileSync(HOME + '/.bitpay/api.key').toString();
var config = require('../config');
var privkey = bitauth.decrypt(config.keyPassword, encPrivkey);
var client = new BitPay(privkey);

and use that client in the bitpay script's login action, the results is:

Error: { error: 'Unauthorized sin' }
Key associated! Check your email to approve access.

So either way, i can't seem to actually log in such a way that I could run e.g. the examples/create-bill.js example correctly... What am I missing?

Bitpay-rest Payout Example Posting Failing

Hello,
I am trying to use the Payout API, however, it seems that it keeps failing, I am not sure if this is a node-BitPay issue or not, but the example posted also fails. Is the API restricted to certain people, or is the example not up-to-date?

Regards,
Samer

Working keys with livenet ?

Hello

I'm a bit confused about the all thing, I try to implement the php client in my application, so I installed this node package to create the keys.

But the pairing keys I generate doesn't seem to work with my account. I there a way to use these keys in production ?

Like I said I'm really confused !

[Heroku specific] Error: Cannot find module '/app/.bitpay/config.json'

I followed the instructions pretty much to the letter and the client works fine in my local node installation.

However when deploying to Heroku I am getting this error about a missing config

: Error: Cannot find module '/app/.bitpay/config.json'
2016-06-02T16:22:24.716365+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:339:15)
2016-06-02T16:22:24.716366+00:00 app[web.1]:     at Function.Module._load (module.js:290:25)
2016-06-02T16:22:24.716367+00:00 app[web.1]:     at Module.require (module.js:367:17)
2016-06-02T16:22:24.716367+00:00 app[web.1]:     at require (internal/module.js:20:19)
2016-06-02T16:22:24.716368+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/bitpay-rest/lib/rest-client.js:11:20)

any ideas, thanks?

maybe there could be a happy fail path if you have the object in client setup..

image

Facing issue while npm install in windows

I tried to npm install bitpay-rest in windows 10. But I am facing the below issue.
npm install bitpay-rest

[email protected] install G:\bitpay-node\node_modules\secp256k1
node-gyp rebuild

G:\bitpay-node\node_modules\secp256k1>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
'.' is not recognized as an internal or external command,
operable program or batch file.
gyp: Call to './utils/has_lib.sh gmpxx && ./utils/has_lib.sh gmp' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd G:\bitpay-node\node_modules\secp256k1
gyp ERR! node -v v6.11.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "bitpay-rest"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the secp256k1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs secp256k1
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls secp256k1
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! G:\bitpay-node\npm-debug.log

I saw in previous issues that bitcore isn't supported in Windows back in 2014. Is there any update on that cause in
https://bitcore.io/guides/wallet-service
I am unable to find configuration steps for Windows.

Unspecified "error" event

Followed tutorial

var bitpay  = require('bitpay');
var privkey = fs.readFileSync('path/to/private.key');
var client  = bitpay.createClient(privkey);

the app crashes with the following error message

TypeError: Uncaught, unspecified "error" event.
    at TypeError (<anonymous>)
    at emit (events.js:74:15)
    at /Users/gringo/dev/lab/node/node_modules/bitpay/lib/rest-client.js:82:26
    at Request._callback (/Users/gringo/dev/lab/node/node_modules/bitpay/lib/rest-client.js:173:40)
    at Request.self.callback (/Users/gringo/dev/lab/node/node_modules/bitpay/node_modules/request/request.js:198:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/Users/gringo/dev/lab/node/node_modules/bitpay/node_modules/request/request.js:1063:14)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/gringo/dev/lab/node/node_modules/bitpay/node_modules/request/request.js:1009:12)
    at IncomingMessage.emit (events.js:117:20)

node-gyp rebuild error

This package depends on the old version of secp256k1. This throws an error on Windows
'.' is not recognized as an internal or external command,
operable program or batch file.
gyp: Call to './utils/has_lib.sh gmpxx && ./utils/has_lib.sh gmp' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\Sebastian\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:160:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Sebastian\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\xampp\htdocs\RoyaleCase\server\node_modules\secp256k1
gyp ERR! node -v v9.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
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","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install 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\Sebastian\AppData\Roaming\npm-cache_logs\2018-11-07T21_34_50_763Z-debug.log

Please fix this or specify system requirements

Error: Error: Server did not return JSON and gave statusCode 403

After generating the clients private key by using this command
./node_modules/bitpay-rest/bin/bitpay.js keygen
< enter a password, or hit enter for no password >
Generating keys...
Keys saved to: /Users/<your_username>/.bitpay
But when i enter this command ./node_modules/bitpay-rest/bin/bitpay.js pair
Hit enter
write no
Hit enter
write 1
Hit Enter
It gives me the error
Error: Error: Server did not return JSON and gave statusCode 403
at Request.handleResponse [as _callback] (/home/talha/Ammar/server-gotogods/node_modules/bitpay-rest/lib/rest-client.js:210:23)
at Request.self.callback (/home/jt/server/node_modules/request/request.js:185:22)
at Request.emit (events.js:182:13)
at Request. (/home/jt/server/node_modules/request/request.js:1157:10)
at Request.emit (events.js:182:13)
at IncomingMessage. (/home/jt/server/node_modules/request/request.js:1079:12)
at Object.onceWrapper (events.js:273:13)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1092:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

Expose notification mechanism used by BitPay's invoice pages, if possible

Hi there,

I'm currently trying to integrate the BitPay API into a Bitcoin POS system that I'm building. For this system, I would like to get notified as soon as possible once an invoice has been paid. From what I can tell, I have two choices:

  • use the callback mechanism by providing some URL
  • load BitPay's invoice page inside an iframe and hook into the event it posts to the parent window

Both of these options don't seem that attractive to me. The POS itself can't really be reliably reached with a callback and requiring a server just for the callback seems like overkill. Having to run a browser and load the invoice page is also something I'd like to avoid, as this is running on an embedded system.

So ideally, I would like to initiate a connection myself to the BitPay server and subscribe to updates for an invoice. In other words, the same mechanism that the invoice page uses, just without all the extra stuff around it. Digging a bit in the source code, it seems some kind of "event bus" exists, that one can theoretically subscribe to. In the API documentation at https://bitpay.com/api#resource-Applications I also see a call to /invoices/:invoiceId/events with the description "Get a bus token which can be used to subscribe to invoice events". However, I couldn't find any further documentation about this.

I would appreciate it very much, if either:

  • this library is updated so that I can easily subscribe to events for an invoice
  • the documentation is extended, so I can figure out myself how to do this
  • you suggest some other approach that I can use for my point of sale project

Thanks!

Install trouble

We're having trouble installing our modules using the bitpay-rest library locally (because of the problematic request line in client.js that caused or CI server to fail). We can't automate our deploys since installing the dependency fails on lifecycle errors. Calling npm install in a preinstall script is a known antipattern of npm.

invoice Creation always returns the same invoice Id

No matter what I pass on subsequent calls I always get the same response.

This was the body of my POST invoice request:
options.body
"{"fullNotifications":"false","physical":false,"posData":"{ "ref" : 711454, "affiliate" : "spring112" }","price":41,"currency":"USD","orderID":"ahb3c","itemDesc":"ah","buyerName":"ah","buyerAddress1":"ah","buyerAddress2":"a","buyerCity":"a","buyerState":"a","buyerZip":"a","buyerEmail":"a","buyerCountry":"a","guid":"522ca6be-e4c4-1f9b-036f-94fedc724eda","token":"FG5vjmpkL2edgdUkzeLZc8AbAXrMqMsKn8Bikoc4Ryt9"}"

And this is the response:
res.body
"{"facade":"pos/invoice","data":{"url":"https://test.bitpay.com/invoice?id=V8Whuq34SLridy1iMC65xH","posData":"{ "ref" : 711454, "affiliate" : "spring112" }","status":"new","btcPrice":"0.000419","btcDue":"0.000419","price":1,"currency":"USD","exRates":{"USD":2386.01},"buyerTotalBtcAmount":"0.000419","itemDesc":"ah","orderId":"ahb3c","invoiceTime":1499925606832,"expirationTime":1499926506832,"currentTime":1499925964603,"guid":"522ca6be-e4c4-1f9b-036f-94fedc724eda","id":"V8Whuq34SLridy1iMC65xH","lowFeeDetected":false,"btcPaid":"0.000000","rate":2386.01,"exceptionStatus":false,"refundAddressRequestPending":false,"paymentUrls":{"BIP21":"bitcoin:mgKFD2MQyiEjBV6TaoRvvmwrxPoWLMjikr?amount=0.000419","BIP72":"bitcoin:mgKFD2MQyiEjBV6TaoRvvmwrxPoWLMjikr?amount=0.000419&r=https://test.bitpay.com/i/V8Whuq34SLridy1iMC65xH","BIP72b":"bitcoin:?r=https://test.bitpay.com/i/V8Whuq34SLridy1iMC65xH","BIP73":"https://test.bitpay.com/i/V8Whuq34SLridy1iMC65xH"},"bitcoinAddress":"mgKFD2MQyiEjBV6TaoRvvmwrxPoWLMjikr","token":"R34k27T27mdfkjDDEfHNMsoqG51MLgdMGtFwZtcRC46pxtHy481GZBcpF3L5x45Kt"}}"

The price is even different. Once I restart the app I will get a single new invoice ID but then all responses until I restart will return the same response.

What's going on? Why am I not getting new invoices?

Thanks

Newbie guide, thanks a lot

How to integrate bitpay with an ordinary website written by nodejs? After reading the document, I don't understand it very well. Can it be related to our system, just like traditional payment? How does the bitpay rest API accomplish this?

What's the difference between pos and merchant?

Thank you for any help!

  • I've registered a bitpay developer
  • I downloaded the bitpay wallet and created the test address

EventParser error at using event bus

I see this error at trying to use an event bus

merchant facade

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /Users/zestu/Finance/BitPayService/node_modules/bitpay-rest/lib/event-parser.js:35:26
    at Array.forEach (<anonymous>)
    at /Users/zestu/Finance/BitPayService/node_modules/bitpay-rest/lib/event-parser.js:27:11
    at Array.forEach (<anonymous>)
    at EventParser._transform (/Users/zestu/Finance/BitPayService/node_modules/bitpay-rest/lib/event-parser.js:22:12)
    at EventParser.Transform._read (_stream_transform.js:190:10)
    at EventParser.Transform._write (_stream_transform.js:178:12)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)

Here's the code I use:

app.get("/create_bitpay_invoice", (req, res, next) => {

    client.as('merchant').post('invoices', data, function(err, invoice) {

        if (err) {
            // more error handling
            return console.log(err);
        } else {
            // success
            // get event bus token
            client.as('merchant').get(invoice.path + 'events', function(err, buspass) {
                if (err) console.log(err);

                let data = {
                    token: buspass.token,
                    action:'subscribe',
                    events: ['payment']
                };
                // pipe event stream request through bitpay.EventParser
                var events = client.as('merchant').get('events', data);
                var parser = new bitpay.EventParser();

                events.pipe(parser).on('payment', function(invoice) {

                    console.log('invoice is ' + invoice.status);
                });

                res.json({msg: invoice});
            });
        }
    });
});

Readme CLI references

The README examples assume a global installation with commands such as $ bitpay, instead of $ ./bin/bitpay. Need to update references to the CLI, and possible include a pairing example for a node script.

Bitpay-rest not compiling on linux due to bignum

On my development server on my mac everything is working properly (It uses node-gyp my dev env to compile code after it fails. ) but when trying to move the code into our staging environment on a linux vm big num refuses to install, and the whole process fails.

Im running 7.7.1 after my upgrade, ive tried on ver 8 and 6 as well. Anyone have any quick solutions?

`sudo npm install bitpay-rest --save

bignumÉ0.12.5 install /home/Co1n/node_modules/bignum
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://rvagg-node.s3-us-west-2.amazonaws.com/bignum/v0.12.5/bignum-v0.12.5-node-v51-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bignumÉ0.12.5 and nodeÉ7.7.1 (node-v51 ABI)

(falling back to source compile with node-gyp)
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/7.7.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/Co1n/node_modules/bignum/.node-gyp"
make: Entering directory '/home/Co1n/node_modules/bignum/build'
make: *** No rule to make target '../.node-gyp/7.7.1/include/node/common.gypi', needed by 'Makefile'. Stop.
make: Leaving directory '/home/Co1n/node_modules/bignum/build'
gyp ERR! build error
gyp ERR! stack Error: émakeé failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 3.16.0-4-amd64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/Co1n/node_modules/bignum/binding/bignum.node" "--module_name=bignum" "--module_path=/home/Co1n/node_modules/bignum/binding"
gyp ERR! cwd /home/Co1n/node_modules/bignum
gyp ERR! node -v v7.7.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.j
s build --fallback-to-build --module=/home/Co1n/node_modules/bignum/binding/bignum.node --module_name=bignum --module_path=/home/Co1n/node
_modules/bignum/binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/Co1n/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:194:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:899:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Linux 3.16.0-4-amd64
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/Co1n/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/Co1n/node_modules/bignum
node-pre-gyp ERR! node -v v7.7.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --m
odule=/home/Co1n/node_modules/bignum/binding/bignum.node --module_name=bignum --module_path=/home/Co1n/node_modules/bignum/binding' (1)
HDCryptoÉ /home/Co1n
└── (empty)
npm WARN HDCryptoÉ No description
npm WARN HDCryptoÉ No repository field.
npm WARN HDCryptoÉ No license field.
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "bitpay-rest" "--save"
npm ERR! node v7.7.1
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! bignumÉ0.12.5 install: énode-pre-gyp install --fallback-to-buildé
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bignumÉ0.12.5 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bignum package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bignum
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bignum
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/Co1n/npm-debug.log`

I even tried installing with --unsafe-perm

./node_modules/bitpay-rest/bin/bitpay.js keygen

./node_modules/bitpay-rest/bin/bitpay.js keygen module.js:472 throw err; Ü Error: Cannot find module '/home/surag_sheth/.bitpay/config.json' at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object.<anonymous> (/home/Co1n/node_modules/bitpay-rest/lib/rest-client.js:11:20) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3)

Please Help, Cheers !

npm install does not work

It failed on Win8.1 and on Ubuntu 12.04 in a VM.

npm ERR! [email protected] install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.

Edit: It works here on Ubuntu 14.04, I guess there were some dependencies missing such as node-gyp?

'Invalid signature' response on AWS

I receive error: Error: { error: 'Invalid signature' } on request GET: https://test.bitpay.com:443/tokens. But signature is right because I can get token via Postman using the same headers.

I'm using bitpay-rest lib and AWS Lambda.

how to get this module to work

After an afternoon of struggling with this thing and its documentation, I'm going to share how I was able to create a basic invoice. Bitpay: please update and improve the docs, feel free to use any of this.

Install and Setup Bitpay Module (*nix platform)

NOTE: the bitpay module automatically creates a .bitpay directory in your home directory that contains your public & private key, and config file. If you want that stuff stored elsewhere (and you probably do, especially if your app runs as a different user), do this first:

export HOME=/path/where/you/want/the/.bitpay/directory

Then install the bitpay module. Note that we're also installing the bitauth module (it's required later on for decrypting your private key when making requests).

npm install bitpay bitauth

Set up your client's private key:

./node_modules/bitpay/bin/bitpay.js keygen
< enter a password, or hit enter for no password >

Next set the environment. Bitpay's test platform is used by default, so if you want to use the regular production platform (ie. bitpay.com and not test.bitpay.com), do this:

./node_modules/bitpay/bin/bitpay.js config --use prod

Next you have to pair up your client's private key with your bitpay account. This is done by requesting a pairing code:

./node_modules/bitpay/bin/bitpay.js pair
Do you have a pairing code?
no < hit enter twice >
Okay, we can get a pairing code, please choose a facade:
  1) Point of Sale
  2) Merchant
  : 
1

This will spit out a bunch of output. At the end of it will be a URL:

 Pair this client with your organization: 
 https://bitpay.com/api-access-request?pairingCode=XXX

Visit this URL in your browser and hit the approve button. Afterwards, you can test creating a basic invoice from the command line like this:

./node_modules/bitpay/bin/bitpay.js request -T pos -X post -R invoices -P '{"price": 1, "currency": "USD"}'

If it worked, you'll see some JSON outputted regarding the newly created invoice. If you get an error like this:

Error: { error: 'Invalid token' }

It's probably because you specified the "Merchant" facade (option 2) when generating your pairing code. For invoices, you want the "Point of Sale" facade (option 1).

Usage in Node.js

Here's how you can create a basic invoice:

// NOTE: if you changed your home environment variable
// when installing bitpay, you'll need to change it again in your code
// before requiring the bitpay module.  If not, just require the bitpay module
// without messing with the process.env.HOME variable
var home = process.env.HOME;
process.env.HOME = '/path/where/you/want/the/.bitpay/directory';
var bitpay = require('bitpay');

// and change it back
process.env.HOME = home;

// need bitauth too
var bitauth = require('bitauth');

// NOTE: necessary to decrypt your key even if you didn't enter a password when you generated it.
// If you did specify a password, pass it as the first param to bitauth.decrypt()
var privkey = bitauth.decrypt('', fs.readFileSync('/path/to/.bitpay/api.key', 'utf8'));

var client = bitpay.createClient(privkey);
client.on('error', function(err) {
    // handle client errors here
    console.log(err);
});
client.on('ready', function(){
        var data = {
        price: 1,
        currency: 'USD'
    };

    // NOTE: the .as('pos') is necessary for Point of Sale requests, 
        // otherwise you'll get an "Invalid token" error
    client.as('pos').post('invoices', data, function(err, invoice) {
        if (err){
            // more error handling
            console.log(err);
        }
        else{
            // success
            console.log('invoice data', invoice);
        }
    });
});

Arguments for creating invoices can be viewed here: https://bitpay.com/api#resource-Invoices

Also, the current README and examples bundled in this module conflict, but the examples are more accurate, so it's best to use them as a starting point.

Hope this helps someone else.

Error: ESOCKETTIMEDOUT in request.js

We're getting the following uncaught error originating from request.js

We're using try catch and promises wherever possible.

9xj7
2016-12-05 15:08:18+01:00Error: ESOCKETTIMEDOUT
9xj7
2016-12-05 15:08:18+01:00 at ClientRequest.<anonymous> (/app/bundle/programs/server/npm/node_modules/custom/node_modules/bitpay/node_modules/request/request.js:825:19)
9xj7
2016-12-05 15:08:18+01:00 at ClientRequest.g (events.js:260:16)
9xj7
2016-12-05 15:08:18+01:00 at emitNone (events.js:67:13)
9xj7
2016-12-05 15:08:18+01:00 at ClientRequest.emit (events.js:166:7)
9xj7
2016-12-05 15:08:18+01:00 at TLSSocket.emitTimeout (_http_client.js:575:10)
9xj7
2016-12-05 15:08:18+01:00 at TLSSocket.g (events.js:260:16)
9xj7
2016-12-05 15:08:18+01:00 at emitNone (events.js:67:13)
9xj7
2016-12-05 15:08:18+01:00 at TLSSocket.emit (events.js:166:7)
9xj7
2016-12-05 15:08:18+01:00 at TLSSocket.Socket._onTimeout (net.js:332:8)
9xj7
2016-12-05 15:08:18+01:00 at _runOnTimeout (timers.js:524:11)
9xj7
2016-12-05 15:08:18+01:00 at _makeTimerTimeout (timers.js:515:3)
9xj7
2016-12-05 15:08:18+01:00 at Timer.unrefTimeout (timers.js:584:5)

[Now specific] Cannot find module '/home/nowuser/.bitpay/config.json'

I followed the instructions while setting up the bitpay client and have no trouble running this in my local environment. However, when deploying to now.sh, I am receiving the error:

`

module.js:557
throw err;
^
Error: Cannot find module '/home/nowuser/.bitpay/config.json'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
`

I have used the overloading configuration option specified in the documentation but it still tries to load the config.json file. I've created a folder named .bitpay in the root and it still isn't able to find the file.

Typically the deployment is served from '/home/nowuser/src' and bitpay is looking for the .bitpay file one level up at 'home/nowuser/.bitpay'

Any help would be appreciated!

Issue with npm install

When i do npm i bitpay, i get the following error:

PS C:\Users\User\Desktop\Work\neidhartandr> npm install bitpay
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json.729148718
npm ERR! dest C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json.729148718' -> 'C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json'
npm ERR!  [OperationalError: EPERM: operation not permitted, rename 'C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json.729148718' -> 'C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, rename 'C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json.729148718' -> 'C:\Users\User\Desktop\Work\neidhartandr\node_modules\ajv\package.json'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'rename',
npm ERR!     path: 'C:\\Users\\User\\Desktop\\Work\\neidhartandr\\node_modules\\ajv\\package.json.729148718',
npm ERR!     dest: 'C:\\Users\\User\\Desktop\\Work\\neidhartandr\\node_modules\\ajv\\package.json'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\User\\Desktop\\Work\\neidhartandr\\node_modules\\ajv\\package.json.729148718',
npm ERR!   dest: 'C:\\Users\\User\\Desktop\\Work\\neidhartandr\\node_modules\\ajv\\package.json',
npm ERR!   parent: 'neidhartandr'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2020-12-06T05_26_17_981Z-debug.log

However, I can install all other node modules perfectly normal.

Maximum length of invoice id ?

I've looked at Bitcoin Payment Gateway API docs and didn't see it mentioned.
Is there a maximum length for an invoice id?
Thanks

ES6 / webpack support

I think there's a problem with the paths.

Sometimes it's looking for the wrong modules e.g. /Users/gringo/dev/bitwala/bitwala/v2/node_modules/bitauth/lib/bitauth.js the filename is actually bitauth-node.js.

While processing files with webpack:webpack (for target os.osx.x86_64):
   src/server.js: ./~/bitauth/lib/bitauth.js
   Module build failed: Error: ENOENT, open
   '/Users/gringo/dev/bitwala/bitwala/v2/node_modules/bitauth/lib/bitauth.js'
   @ ./~/bitauth/index.js 2:14-38
   src/server.js: ./~/bignum/test/buf.js
   Module not found: Error: Cannot resolve module 'put' in
   /Users/gringo/dev/bitwala/bitwala/v2/node_modules/bignum/test
   resolve module put in /Users/gringo/dev/bitwala/bitwala/v2/node_modules/bignum/test
   looking for modules in /Users/gringo/dev/bitwala/bitwala/v2/src
   /Users/gringo/dev/bitwala/bitwala/v2/src/put doesn't exist (module as directory)
   resolve 'file' put in /Users/gringo/dev/bitwala/bitwala/v2/src
   resolve file
   /Users/gringo/dev/bitwala/bitwala/v2/src/put doesn't exist
   /Users/gringo/dev/bitwala/bitwala/v2/src/put.js doesn't exist
   /Users/gringo/dev/bitwala/bitwala/v2/src/put.jsx doesn't exist
   /Users/gringo/dev/bitwala/bitwala/v2/src/put.css doesn't exist
   looking for modules in /Users/gringo/dev/bitwala/bitwala/v2/node_modules
   /Users/gringo/dev/bitwala/bitwala/v2/node_modules/put doesn't exist (module as directory)
   resolve 'file' put in /Users/gringo/dev/bitwala/bitwala/v2/node_modules
   resolve file
   /Users/gringo/dev/bitwala/bitwala/v2/node_modules/put doesn't exist
   /Users/gringo/dev/bitwala/bitwala/v2/node_modules/put.js doesn't exist
   /Users/gringo/dev/bitwala/bitwala/v2/node_modules/put.jsx doesn't exist
   /Users/gringo/dev/bitwala/bitwala/v2/node_modules/put.css doesn't exist
   [/Users/gringo/dev/bitwala/bitwala/v2/src/put]
   [/Users/gringo/dev/bitwala/bitwala/v2/src/put]
   [/Users/gringo/dev/bitwala/bitwala/v2/src/put.js]
   [/Users/gringo/dev/bitwala/bitwala/v2/src/put.jsx]
   [/Users/gringo/dev/bitwala/bitwala/v2/src/put.css]
   [/Users/gringo/dev/bitwala/bitwala/v2/node_modules/put]
   [/Users/gringo/dev/bitwala/bitwala/v2/node_modules/put]
   [/Users/gringo/dev/bitwala/bitwala/v2/node_modules/put.js]
   [/Users/gringo/dev/bitwala/bitwala/v2/node_modules/put.jsx]
   [/Users/gringo/dev/bitwala/bitwala/v2/node_modules/put.css]
   @ ./~/bignum/test/buf.js 3:10-24
   src/server.js: ./~/tough-cookie/package.json
   Module parse failed: /Users/gringo/dev/bitwala/bitwala/v2/node_modules/tough-cookie/package.json
   Line 2: Unexpected token :
   You may need an appropriate loader to handle this file type.
   | {
   |   "_args": [
   |     [
   |       "tough-cookie@~2.2.0",
   @ ./~/tough-cookie/lib/cookie.js 38:14-40
   src/server.js: ./~/hawk/package.json
   Module parse failed: /Users/gringo/dev/bitwala/bitwala/v2/node_modules/hawk/package.json Line 2:
   Unexpected token :
   You may need an appropriate loader to handle this file type.
   | {
   |   "_args": [
   |     [
   |       "hawk@~3.1.3",
   @ ./~/hawk/lib/utils.js 14:11-37
   src/server.js: ./~/mime-db/db.json
   Module parse failed: /Users/gringo/dev/bitwala/bitwala/v2/node_modules/mime-db/db.json Line 2:
   Unexpected token :
   You may need an appropriate loader to handle this file type.
   | {
   |   "application/1d-interleaved-parityfec": {
   |     "source": "iana"
   |   },
   @ ./~/mime-db/index.js 11:17-37
   src/server.js: ./~/har-validator/lib/schemas/cache.json
   Module parse failed:
   /Users/gringo/dev/bitwala/bitwala/v2/node_modules/har-validator/lib/schemas/cache.json Line 2:
   Unexpected token :
   You may need an appropriate loader to handle this file type.
   | {
   |   "properties": {
   |     "beforeRequest": {
   |       "$ref": "#cacheEntry"
   @ ./~/har-validator/lib/schemas/index.js 4:9-32
   src/server.js: ./~/har-validator/lib/schemas/content.json
   Module parse failed:

How can we complete pairing using bitpay-rest in prod in a Docker container?

As I understand it, in order to make Point of Sale requests, I need to run bitpay.js pair, go through the command line prompts, and eventually follow that link and press the approve button. That seems to make sense, but I'm trying to run bitpay-rest in a Docker container and don't know how to complete pairing inside it. Can it be done? And is it possible to automate those steps?

Update: After thinking about it more, it seems like I could run a setup script in my Dockerfile that runs through the pairing process, and I'll provide input to the interactive prompts somehow...but what about clicking the link with the pairing code? Can that be automated? Or is there a different approach I should be using to avoid the pairing code step entirely?

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.