Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

btc-script

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

btc-script - npm Package Compare versions

Comparing version 0.1.4 to 0.1.7

4

CHANGELOG.md

@@ -0,1 +1,5 @@

0.1.7 / 2014-04-09
-----------------
* Multisig Escrows Addresses Support
0.1.4 / 2014-04-05

@@ -2,0 +6,0 @@ -----------------

@@ -240,4 +240,15 @@ var Opcode = require('btc-opcode');

return 'scripthash';
} else if (this.chunks[this.chunks.length - 1] === Opcode.map.OP_CHECKMULTISIG) {
// if script ends with OP_CHECKMULTISIG
} else if (this.chunks.length > 3 &&
// m is a smallint
isSmallIntOp(this.chunks[0]) &&
// n is a smallint
isSmallIntOp(this.chunks[this.chunks.length - 2]) &&
// n greater or equal to m
this.chunks[0] <= this.chunks[this.chunks.length - 2] &&
// n cannot be 0
this.chunks[this.chunks.length - 2] !== Opcode.map.OP_0 &&
// n is the size of chunk length minus 3 (m, n, OP_CHECKMULTISIG)
this.chunks.length - 3 === this.chunks[this.chunks.length - 2] - Opcode.map.OP_RESERVED &&
// last chunk is OP_CHECKMULTISIG
this.chunks[this.chunks.length - 1] == Opcode.map.OP_CHECKMULTISIG) {
return 'multisig'

@@ -250,2 +261,8 @@ } else if (this.chunks[0] === Opcode.map.OP_RETURN) {

}
function isSmallIntOp(opcode) {
return ((opcode == Opcode.map.OP_0) ||
((opcode >= Opcode.map.OP_1) && (opcode <= Opcode.map.OP_16)));
};
/**

@@ -281,2 +298,28 @@ * Returns the address corresponding to this output in hash160 form.

/*
returns an array of addresses
*/
Script.prototype.toAddresses = function(network) {
var self = this;
var outType = this.getOutType();
var addresses = [];
if (outType === 'multisig') {
for (var i = 1, last = self.chunks.length - 2; i < last; i++) {
addresses.push(new Address(cryptoHash.ripemd160(cryptoHash.sha256(self.chunks[i], {
out: 'bytes'
}), {
out: 'bytes'
}), 'pubkeyhash', network || Script.defaultNetwork))
}
return addresses
} else {
var address = self.toAddress()
if (address) {
return [address]
} else {
return false
}
}
}
/**

@@ -283,0 +326,0 @@ * Compare the script to known templates of scriptSig.

4

package.json
{
"name": "btc-script",
"version": "0.1.4",
"version": "0.1.7",
"description": "Script support for Bitcoin.",

@@ -29,2 +29,2 @@ "keywords": [

}
}
}
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