bitpay / bitcore-channel Goto Github PK
View Code? Open in Web Editor NEWPayment channels smart contract support for bitcore.
License: MIT License
Payment channels smart contract support for bitcore.
License: MIT License
at 03.broadcastCommitment.js
var commitment = JSON.parse(fs.readFileSync('commitment.log'));
consumer.commitmentTx = new Commitment(commitment);
assert(consumer.commitmentTx.isFullySigned());
this.clearOutputs();
no such clearOutputs function in bitcore.js or bitcore-channel.js
That 89% is annoying
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);
...
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')));
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();
Copying from bitpay/bitcore#1059
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?
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?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.