Code Monkey home page Code Monkey logo

bitcore-payment-protocol's Introduction

bitcore-payment-protocol's People

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

Watchers

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

bitcore-payment-protocol's Issues

.Output#messageType is not a field: undefined

I'm creating an output for the payment details, but upon running the request I get the error: ".Output#messageType is not a field: undefined"

If I print the output to the console this is what I get:

{ messageType: 'Output',
  message:
   { amount: { low: 10, high: 0, unsigned: true },
     script:
      { buffer: <Buffer 4f 00 50 00 5f 00 44 00 55 00 50 00 20 00 4f 00 50 00 5f 00 48 00 41 00 53 00 48 00 31 00 36 00 30 00 20 00 32 00 30 00 20 00 30 00 78 00 30 00 36 00 33 ...>,
        offset: 0,
        markedOffset: -1,
        limit: 180,
        littleEndian: false,
        noAssert: false } } }

So I assume it's reffering to the messageType: 'Output'

Here's my relevant code:

    //make an output
    var address = bitcore.Address.fromString('1ZquFz5Pc2KLaY1mrZdXD6DyprgtsjiR5');
    var script = bitcore.Script.buildPublicKeyHashOut(address);
    var raw_script = new Buffer(script.toString(), 'ucs2');

    var outputs = new PaymentProtocol().makeOutput();
    outputs.set('amount', 10);
    outputs.set('script', raw_script);

    //Make payment details
    var details = new PaymentProtocol().makePaymentDetails();
    details.set('network', 'main');
    details.set('outputs', outputs);//Issue right here
    details.set('time', now);
    details.set('expires', now + 60 * 60 * 24);
    details.set('memo', 'A payment request from the merchant.');
    details.set('payment_url', 'http://198.199.70.166:8888/ack');
    details.set('merchant_data', new Buffer({size: 7})); 

What's going on here?

Payment request certificate chain

Is it possible to provide a full or a partial certificate chain when issuing a payment request? My domain's certificate was issued by an intermediary which is not stored in rootcerts.json:

AddTrust External CA Root
|__ COMODO RSA Certification Authority
    |__ COMODO RSA Extended Validation Secure Server CA  <--
        |__ MyDomain.com

I've been trying to supply the whole chain as well as a partial one and I couldn't make it work. I think bitcoinj does not have this issue, mycelium testnet is able to correctly verify the signature by verifying the entire chain.

root cert in request must be optional

BIP70 states The trusted root authority MAY be included.
These days in TLS it is commonplace not to include the root cert.
Your code however (in *.verifyCertChain() ) assumes that root cert is present.

Payment Request: Can't figure out how generate a x509 certificate

I just can't find a way to generate such file.

var certificates = new PaymentProtocol().makeX509Certificates();
certificates.set('certificate', [file_with_x509_der_cert]);

Is there any utilities function in the bitcore-payment-protocol API to generate such x509_der_cent file?
I do not have any knowledge in such field, I just assume it has something to deal with HTTPS

NPM warning on module install

Exact warning: "npm WARN optional dep failed, continuing bn.js@~0.13.3"

This was on a Ubuntu 15.10 x64 digitalocean server. Running the most recent version of Node.js.
While the module appears to work, I was wondering what caused this warning?

getTBSCertificate is broken

it relies on finding zero bytes in the tail. But what is the signature itself contains zero bytes?
I'm afraid there is no way around proper asn1 parsing.

Improve docs and ease of use

Setting up payment protocol can be difficulty. Having more examples, docs, tests could be useful for those implementing, and an improved API.

Error: More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.

I'm trying to follow this guide and implement a BIP70 payment protocol. https://bitcore.io/api/paypro

In the guide, it shows two required steps which bitcore-payment-protocol does not provide functionality for. Those two things are:

  1. creating a output
details.set('outputs', outputs);
  1. creating a script
outputs.set('script', script.toBuffer()); // an instance of script

So naturally, I figure I need to use the bitcore-lib library to create an output and a script, to be able to implement BIP70 in Bitcore. So I require it like so:

var PaymentProtocol = require('bitcore-payment-protocol');
var BitcoreLib = require('bitcore-lib');

But that's a no-go, it just makes an error when running

$ node bitcoin.js
/Users/chrisgrimmett/scripts/loluwin/node_modules/bitcore-lib/index.js:12
    throw new Error(message);
          ^
Error: More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.
    at Object.bitcore.versionGuard (/Users/chrisgrimmett/scripts/loluwin/node_modules/bitcore-lib/index.js:12:11)
    at Object.<anonymous> (/Users/chrisgrimmett/scripts/loluwin/node_modules/bitcore-lib/index.js:15:9)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/chrisgrimmett/scripts/loluwin/bitcoin.js:2:18)
    at Module._compile (module.js:460:26)

Looking around at other GitHub issues, and judging by the error message itself, the recommended fix seems to be to "check that submodules do not also include their own bitcore-lib dependency." However that doesn't seem possible in bitcore-payment-protocol...

bitcore-payment-protocol is hard coded to require it's own instance of bitcore-lib and doesn't export a handle, so I don't think I can stop it from including it's own, and I can't "tap into" that instance to implement what I think I need.

Am I doing something wrong?

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.