New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bitcore-channel

Package Overview
Dependencies
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcore-channel - npm Package Compare versions

Comparing version 0.10.1 to 0.11.0

test/signatures.js

2

bower.json
{
"name": "bitcore-channel",
"main": "./bitcore-channel.min.js",
"version": "0.10.1",
"version": "0.11.0",
"homepage": "https://github.com/bitpay/bitcore-channel",

@@ -6,0 +6,0 @@ "authors": [

@@ -132,3 +132,3 @@ 'use strict';

$.checkState(this.commitmentTx.isFullySigned());
var amount = this.commitmentTx.amount;
var amount = this.commitmentTx.amount - this.commitmentTx.getFee();
var multisigOut = {

@@ -141,6 +141,5 @@ txid: this.commitmentTx.id,

this.refundTx = new Refund()
.from(multisigOut, this.commitmentTx.publicKeys, 2)
.change(this.refundAddress);
.from(multisigOut, this.commitmentTx.publicKeys, 2);
this.refundTx.to(this.refundAddress, this.refundTx.inputAmount);
this.refundTx.inputs[0].sequenceNumber = 0;
this.refundTx._updateChangeOutput();
this.refundTx.nLockTime = this.expires;

@@ -160,6 +159,7 @@ return this.refundTx;

refund.sign(this.commitmentKey);
$.checkState(new Address(refund.outputs[0].script, this.network).toString() ===
this.refundAddress.toString());
var receivedAddress = new Address(refund.outputs[0].script, this.network).toString();
$.checkState(receivedAddress === this.refundAddress.toString());
var amount = refund.outputs[0].satoshis;
$.checkState(amount + refund._estimateFee() === this.commitmentTx.amount);
$.checkState(amount === this.commitmentTx.amount - this.commitmentTx.getFee(),
'Refund amount must equal commitmentTx amount');
$.checkState(refund.outputs.length === 1, 'More than expected outputs received');

@@ -169,3 +169,12 @@ $.checkState(refund.isFullySigned(), 'Refund was not fully signed');

refund.inputs[0].script,
refund.inputs[0].output.script
refund.inputs[0].output.script,
refund,
0,
Script.Interpreter.SCRIPT_VERIFY_P2SH
|
Script.Interpreter.SCRIPT_VERIFY_STRICTENC
|
Script.Interpreter.SCRIPT_VERIFY_MINIMALDATA
|
Script.Interpreter.SCRIPT_VERIFY_SIGPUSHONLY
), 'Refund is incorrectly signed');

@@ -172,0 +181,0 @@ this.refundTx = refund;

@@ -51,7 +51,17 @@ 'use strict';

});
$.checkState(!_.isUndefined(newAmount), 'No output found corresponding to paymentAddress');
$.checkState(Script.Interpreter().verify(
payment.inputs[0].script,
payment.inputs[0].output.script
payment.inputs[0].output.script,
payment,
0,
Script.Interpreter.SCRIPT_VERIFY_P2SH
|
Script.Interpreter.SCRIPT_VERIFY_STRICTENC
|
Script.Interpreter.SCRIPT_VERIFY_MINIMALDATA
|
Script.Interpreter.SCRIPT_VERIFY_SIGPUSHONLY
), 'Script did not evaluate correctly (probably a bad signature received)');
$.checkState(!_.isUndefined(newAmount) && newAmount > this.currentAmount,
$.checkState(newAmount > this.currentAmount,
'A payment for a greater amount was already received');

@@ -58,0 +68,0 @@ this.paymentTx = payment;

@@ -7,4 +7,2 @@ 'use strict';

var PrivateKey = require('bitcore').PrivateKey;
var Address = require('bitcore').Address;
var Script = require('bitcore').Script;

@@ -31,3 +29,5 @@ var Transaction = require('bitcore').Transaction;

this.address = this.outscript.toScriptHashOut().toAddress();
this.change(this.address);
if (!this.outputs.length) {
this.change(this.address);
}

@@ -37,6 +37,5 @@ Object.defineProperty(this, 'amount', {

get: function() {
return this._inputAmount;
return this.inputAmount;
}
});
this._updateChange = undefined;
}

@@ -43,0 +42,0 @@ inherits(Commitment, Transaction);

@@ -28,3 +28,6 @@ 'use strict';

this.paymentAddress = new Address(opts.paymentAddress);
this._change = new Address(opts.changeAddress);
this.changeAddress = new Address(opts.changeAddress);
if (!this.outputs.length) {
this.change(this.changeAddress);
}

@@ -36,11 +39,6 @@ this.multisigOut = new Transaction.UnspentOutput(opts.multisigOut);

}
if (this.outputs.length < 2) {
this._updateChangeOutput();
}
this.amount = this.outputAmount;
this.sequence = opts.sequence || 0;
this._fee = FEE_AMOUNT;
this.paid = opts.paid || 0;
$.checkArgument(_.isNumber(this.amount), 'Amount must be a number');
this._changeSetup = undefined;
}

@@ -50,8 +48,5 @@ inherits(Payment, Transaction);

Payment.prototype._updateTransaction = function() {
this.outputs = [];
this._changeOutput = undefined;
this._outputAmount = 0;
this.clearOutputs();
this.to(this.paymentAddress, this.paid);
this.inputs[0].sequence = this.sequence;
this._changeSetup = false;
};

@@ -75,3 +70,3 @@

paymentAddress: this.paymentAddress.toString(),
changeAddress: this._change.toString(),
changeAddress: this.changeAddress.toString(),
transaction: Transaction.prototype.toObject.apply(this)

@@ -78,0 +73,0 @@ };

@@ -12,3 +12,2 @@ 'use strict';

Transaction.apply(this, arguments);
this._changeSetup = undefined;
}

@@ -15,0 +14,0 @@ inherits(Refund, Transaction);

{
"name": "bitcore-channel",
"version": "0.10.1",
"version": "0.11.0",
"description": "Add payment channels support to bitcore",

@@ -10,3 +10,13 @@ "scripts": {

},
"author": "Esteban Ordano <eordano@gmail.com>",
"author": "BitPay <dev@bitpay.com>",
"contributors": [
{
"name": "Esteban Ordano",
"email": "eordano@gmail.com"
},
{
"name": "Manuel Araoz",
"email": "manuelaraoz@gmail.com"
}
],
"keywords": [

@@ -22,6 +32,5 @@ "bitcoin",

"license": "MIT",
"repository": "https://github.com/eordano/bitcore-channel",
"repository": "https://github.com/bitpay/bitcore-channel",
"dependencies": {
"bitcore": "^0.12.0",
"browserify": "^8.1.0",
"bitcore": "^0.12.6",
"inherits": "=2.0.1"

@@ -28,0 +37,0 @@ },

<img src="http://bitcore.io/css/images/module-channel.png" alt="bitcore payment channels" height="35">
# Payment channels for bitcore
# Payment Channels for Bitcore

@@ -4,0 +4,0 @@ [![NPM Package](https://img.shields.io/npm/v/bitcore-channel.svg?style=flat-square)](https://www.npmjs.org/package/bitcore-channel)

@@ -5,3 +5,3 @@ 'use strict';

var bitcore = require('bitcore');
var Networks = require('bitcore/lib/networks');
var Networks = bitcore.Networks;

@@ -28,6 +28,6 @@ describe('Simple Payment Channel usage', function() {

'sequenceNumber': 4294967295,
'script': '483045022100d1905baf6c16cf6c2aefd23f57c000f607bac82eada248fb9ad40d2be46a0f2d022045da95d5b7767f2793f5ea9f8c4240de79ebe6cb8454fec706b8e11dca8fa891012103bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'scriptString': '72 0x3045022100d1905baf6c16cf6c2aefd23f57c000f607bac82eada248fb9ad40d2be46a0f2d022045da95d5b7767f2793f5ea9f8c4240de79ebe6cb8454fec706b8e11dca8fa89101 33 0x03bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'script': '483045022100e5e9a5660ed650b377d1063c57ba210d2f8e36f350489a5b0ca9b46eb8fb659a02205a6d336c2252b39fcb7534fdfc3a593a87b5c34c0d3ad27e25bd5edea027308a012103bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'scriptString': '72 0x3045022100e5e9a5660ed650b377d1063c57ba210d2f8e36f350489a5b0ca9b46eb8fb659a02205a6d336c2252b39fcb7534fdfc3a593a87b5c34c0d3ad27e25bd5edea027308a01 33 0x03bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'output': {
'satoshis': 100000,
'satoshis': 50000000,
'script': '76a91469b678f36c91bf635ff6e9479edd3253a5dfd41a88ac'

@@ -39,6 +39,6 @@ }

'sequenceNumber': 4294967295,
'script': '483045022100c3d8097771be0850c8134d1ff8fc854a4ad004b538cf19b08cb9e5d4734fa972022017f976bfdfc3ec8af5117eb07e2ed8588110ede7b21a4a9202cc239497c94bc3012103bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'scriptString': '72 0x3045022100c3d8097771be0850c8134d1ff8fc854a4ad004b538cf19b08cb9e5d4734fa972022017f976bfdfc3ec8af5117eb07e2ed8588110ede7b21a4a9202cc239497c94bc301 33 0x03bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'script': '47304402205d5c5ae33804c2842311bedca88474ee47d49efba2a3aece49e7039551cc98b00220338b5aed644a810b0d92c9717029a1dfe3808f8a5ce74ec4f5cc03c6a7af2148012103bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'scriptString': '71 0x304402205d5c5ae33804c2842311bedca88474ee47d49efba2a3aece49e7039551cc98b00220338b5aed644a810b0d92c9717029a1dfe3808f8a5ce74ec4f5cc03c6a7af214801 33 0x03bca86b6a422d1ffec9fd0a1e8d37feaef4e41f76bbdde68852251b7ae8ca6fab',
'output': {
'satoshis': 1000000,
'satoshis': 10000000,
'script': '76a91469b678f36c91bf635ff6e9479edd3253a5dfd41a88ac'

@@ -48,3 +48,3 @@ }

'outputs': [{
'satoshis': 1090000,
'satoshis': 59990000,
'script': 'a914fdeaa734587dfed0090c98fbf1bf8730009ddda887'

@@ -56,6 +56,3 @@ }],

},
'publicKeys': [
'027f10e67bea70f847b3ab92c18776c6a97a78f84def158afc31fd98513d42912e',
'023bc028f67697712efeb0216ef1bc7208e2c9156bf0731204d79328f4c8ef643a'
],
'publicKeys': ['027f10e67bea70f847b3ab92c18776c6a97a78f84def158afc31fd98513d42912e', '023bc028f67697712efeb0216ef1bc7208e2c9156bf0731204d79328f4c8ef643a'],
'network': 'testnet'

@@ -68,3 +65,3 @@ };

var consumer = getFundedConsumer().consumer;
consumer.commitmentTx.amount.should.equal(1100000);
consumer.commitmentTx.amount.should.equal(60000000);
});

@@ -125,2 +122,15 @@

});
it('calculates fees normally', function() {
var provider = getProvider();
var consumer = getValidatedConsumer().consumer;
provider.validPayment(consumer.incrementPaymentBy(1000));
provider.currentAmount.should.equal(1000);
provider.paymentTx.getFee().should.equal(10000);
provider.validPayment(consumer.incrementPaymentBy(1000));
provider.validPayment(consumer.incrementPaymentBy(1000));
provider.validPayment(consumer.incrementPaymentBy(1000));
provider.currentAmount.should.equal(4000);
provider.paymentTx.getFee().should.equal(10000);
});
});

@@ -163,3 +173,3 @@ });

'scriptPubKey': '76a91469b678f36c91bf635ff6e9479edd3253a5dfd41a88ac',
'amount': 0.001,
'amount': 0.5,
'confirmationsFromCache': false

@@ -172,3 +182,3 @@ }, {

'scriptPubKey': '76a91469b678f36c91bf635ff6e9479edd3253a5dfd41a88ac',
'amount': 0.01,
'amount': 0.1,
'confirmations': 18,

@@ -175,0 +185,0 @@ 'confirmationsFromCache': false

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc