Giter Club home page Giter Club logo

bitcore-channel's Introduction

bitcore payment channels

# Payment Channels for Bitcore

NPM Package Build Status Coverage Status

A module for bitcore that implements Payment Channels. Payment channels (sometimes referred as micropayment channels) are a type of smart contracts that allow rapidly adjusting bitcoin transactions. This can be used to do trustless simultaneous payments with a service provider without the need of an intermediary, and some other applications.

See the main bitcore repo or the bitcore guide on Payment Channels for more information.

Contributing

See CONTRIBUTING.md on the main bitcore repo for information about how to contribute.

License

Code released under the MIT license.

Copyright 2013-2015 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.

bitcore-channel's People

Contributors

braydonf avatar eordano avatar maraoz avatar pnagurny avatar trevinhofmann avatar unusualbob avatar yemel 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

Watchers

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

bitcore-channel's Issues

validateRefund wipes refundTx output

the first line in validateRefund:

refund = new Refund(refund);

overwrites some parts of refund, eliminating the output, which is immediately referenced in the third line in validateRefund:

var receivedAddress = new Address(refund.outputs[0].script, this.network).toString();

Helpful detail for Developer Guide

It might be a good idea to add an example to the payment channel portion of the developer guide for the case that the provider simply returns a signature of the refund, not the refund itself. It took me a while to figure out I needed to make a TransactionSignature:

            var signature = new TransactionSignature({
                signature: signature_string,
                prevTxId: consumer.commitmentTx.hash,
                outputIndex: 0,
                inputIndex: 0,
                publicKey: server_key,
                sigtype: sigtype
            });

            try
            {
                refund_tx.applySignature(signature);

...

Update examples with the latest version of bitcore v0.13.x

examples/01.createChannel.js
fs.writeFileSync('unsigned.refund.log', consumer.setupRefund().toJSON());
write [object Object]

so that is not working
examples/02.signRefund.js
var refund = JSON.parse(String(fs.readFileSync('unsigned.refund.log')));

Lowercase naming convention

All of the bitcore modules use a lowercase naming convention, e.g.lib/privatekey.js, for the purposes of consistency, we should standardize on this to avoid common typing mistakes.

setupRefund() failing

hi there,

when following the docs and examples to set up a channel, i get this error:

bitcore-channel.js:140 Uncaught TypeError: Cannot read property 'script' of undefined

this happens because outputs[] is empty. the insight api call however does return utxo transactions. so i assume that something in Consumer.processFunding() is not parsing them properly.

my code:

var consumer = new Consumer({
  network: 'testnet',
  fundingKey: fundingKey,
  refundKey: refundKey,
  commitmentKey: commitmentKey,
  providerPublicKey: providerPublicKey,
});

var insight = new Insight(bitcore.Networks.testnet);
insight.getUnspentUtxos(consumer.fundingAddress, function(err, utxos) {
  consumer.processFunding(utxos);
  consumer.setupRefund();
});

any clues?

Are signatures properly checked?

The consumer validates the refund in validateRefund(),
and the the provider validates paments in validatePayment(), both by doing

Script.Interpreter().verify( *.inputs[0].script, *.inputs[0].output.script )

However, this call does not provide the spending transaction, which should be required since the scriptSig (*.inputs[0].script) contains a multisig redeem script based on OP_CHECKMULTISIG?

As the docs for verify() state:

@param {Transaction=} tx - the Transaction containing the scriptSig in one input (used * to check signature validity for some opcodes like OP_CHECKSIG)

The flag argument, which allows validation of P2SH by using Interpreter.SCRIPT_VERIFY_P2SH, is also missing.

Does this actually do a proper signature check?

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.