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

bitcore-doichain

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcore-doichain - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

19

index.js

@@ -34,2 +34,6 @@ var bitcore = require('bitcore');

Opcode.map['OP_NAME_DOI'] = constants.NAME_DOI_OPCODE;
Opcode.map['10'] = constants.NAME_DOI_OPCODE;
Opcode.OP_NAME_DOI = constants.NAME_DOI_OPCODE;
// Namecoin:

@@ -39,4 +43,4 @@ // Version Bytes:

var networkNamecoin = Networks.add({
name: 'namecoin',
alias: 'namecoin',
name: 'doichain',
alias: 'doichain',
// https://github.com/namecoin/namecore/commit/4b33389f2ed7809404b1a96ae358e148a765ab6f

@@ -69,3 +73,3 @@ pubkeyhash: 0x34,

Script.prototype.isNameOut = function() {
return this.isNameNew() || this.isNameFirstUpdate() || this.isNameUpdate();
return this.isNameNew() || this.isNameFirstUpdate() || this.isNameUpdate() || this.isNameDoi();
};

@@ -76,3 +80,3 @@

this.isNameFirstUpdate() ||
this.isNameUpdate(), 'Non-Namecoin script output');
this.isNameUpdate() || this.isNameDoi(), 'Non-Namecoin script output');
// TODO: sanity check on pubKey hash length / type

@@ -87,2 +91,4 @@ // otherwise the errors moving forward are cryptic

return this.chunks[7].buf;
case Opcode.OP_NAME_DOI:
return this.chunks[7].buf;
default:

@@ -105,2 +111,6 @@ throw new Error('Non-Namecoin script output');

Script.prototype.isNameDoi = function() {
return this.chunks[0].opcodenum === Opcode.OP_NAME_DOI;
};
Transaction.prototype._fromNonP2SH = NameInput.patchFromNonP2SH; //patchFromNonP2SH;

@@ -113,3 +123,4 @@ Transaction.Input.NameInput = require('./lib/nameinput.js');

Transaction.prototype.nameUpdate = names.nameUpdate;
Transaction.prototype.nameDoi = names.nameDoi;
module.exports = bitcore;

@@ -23,2 +23,3 @@ var bitcore = require('bitcore');

NAME_UPDATE_OPCODE: 83,
NAME_DOI_OPCODE: 90,

@@ -25,0 +26,0 @@ // transactions with name_* opcodes get this version number

@@ -101,4 +101,4 @@ 'use strict';

return function(utxo) {
if (utxo.script.isNameOut()) {
// console.log(utxo)
/*if (utxo.script.isNameOut()) {
var clazz = NameInput;

@@ -114,5 +114,5 @@ return this.addInput(new clazz({

}));
} else {
} else {*/
return originalFn.call(this, utxo);
}
//}
};

@@ -119,0 +119,0 @@ })();

@@ -1,2 +0,2 @@

var nmcTx = require('namecoin-transaction');
var doiTx = require('doichain-transaction');
var hash = require('crypto-hashing');

@@ -48,3 +48,3 @@ var conv = require('binstring');

$.checkState( name.length < constants.NAME_MAX_LENGTH, 'Name too long.');
var nameNewAsm = nmcTx.newName( name, randHex( rand), address);
var nameNewAsm = doiTx.newName( name, randHex( rand), address);
var nameNewOut = makeOutput({

@@ -64,3 +64,3 @@ script: nameNewAsm,

$.checkState( value.length < constants.VALUE_MAX_LENGTH, 'Value too long.');
var nameFirstUpdateAsm = nmcTx.nameFirstUpdate(
var nameFirstUpdateAsm = doiTx.nameFirstUpdate(
name, randHex( rand), value, address

@@ -81,3 +81,3 @@ );

$.checkState( value.length < constants.VALUE_MAX_LENGTH, 'Value too long.');
var nameUpdate = nmcTx.nameUpdate( name, value, address);
var nameUpdate = doiTx.nameUpdate( name, value, address);
var nameUpdateOut = makeOutput({

@@ -92,6 +92,21 @@ script: nameUpdate,

function nameDoi( name, value, address) {
$.checkState( name && value && address, 'Missing args.');
$.checkState( name.length < constants.NAME_MAX_LENGTH, 'Name too long.');
$.checkState( value.length < constants.VALUE_MAX_LENGTH, 'Value too long.');
var nameDoi = doiTx.nameDoi( name, value, address);
var nameDoiOut = makeOutput({
script: nameDoi,
satoshis: constants.NETWORK_FEE.satoshis
});
this.addOutput( nameDoiOut);
this.version = constants.NAMECOIN_TX_VERSION;
return this;
}
module.exports = {
nameNew: nameNew,
nameFirstUpdate: nameFirstUpdate,
nameUpdate: nameUpdate
nameUpdate: nameUpdate,
nameDoi: nameDoi
};

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

var opcodenum = Opcode(data).toNumber();
console.log("opcodenum",opcodenum)
return {

@@ -105,2 +106,20 @@ opcodenum: opcodenum

/**
* Take a chunk of ASM string parts and deteriming whether or not we're
* given a valid name update ASM script.
*/
var isNameDoi = function(strChunks){
console.log('isNameDOI',Opcode.OP_NAME_DOI)
return strChunks.length === 10 &&
( Opcode(strChunks[0]).toNumber() === Opcode.OP_NAME_DOI) &&
strChunks[1].match( '[a-f0-9]{1,255}') &&
strChunks[2].match( '[a-f0-9]{1,1024}') &&
Opcode(strChunks[3]).toNumber() === Opcode.OP_2DROP &&
Opcode(strChunks[4]).toNumber() === Opcode.OP_DROP &&
Opcode(strChunks[5]).toNumber() === Opcode.OP_DUP &&
Opcode(strChunks[6]).toNumber() === Opcode.OP_HASH160 &&
strChunks[7].match( '[a-f0-9]{40}') &&
Opcode(strChunks[8]).toNumber() === Opcode.OP_EQUALVERIFY &&
Opcode(strChunks[9]).toNumber() === Opcode.OP_CHECKSIG;
};

@@ -163,3 +182,23 @@ /**

/**
* Take a list of ASM script opcode chunks
* and return a list of objects used to generate
* a valid serialized name_update script.
*/
var parseNameDoi = function(chunks){
return [
scriptOpcode(chunks[0]),
scriptStrBuf(chunks[1]),
scriptStrBuf(chunks[2]),
scriptOpcode(chunks[3]),
scriptOpcode(chunks[4]),
scriptOpcode(chunks[5]),
scriptOpcode(chunks[6]),
scriptStrBuf(chunks[7]),
scriptOpcode(chunks[8]),
scriptOpcode(chunks[9]) ];
};
/**
* If we're passed a namecoin ASM script,

@@ -190,2 +229,6 @@ * convert the ASM script string into a bitcore Script instance.

return script;
} else if (isNameDoi(chunks)) {
parsed = parseNameDoi(chunks);
script.chunks = parsed
return script;
} else {

@@ -192,0 +235,0 @@ // otherwise, execute old code

{
"name": "bitcore-doichain",
"version": "0.0.5",
"version": "0.0.6",
"description": "Doichain Support for Bitcore",

@@ -24,3 +24,3 @@ "author": "Brandon Roberts <brandon@bxroberts.org>",

"type": "git",
"url": "https://github.com/brandonrobertz/bitcore-namecoin.git"
"url": "https://github.com/doichain/bitcore-doichain.git"
},

@@ -33,3 +33,3 @@ "dependencies": {

"lodash": "^3.10.1",
"namecoin-transaction": "^0.0.1"
"doichain-transaction": "^0.0.2"
},

@@ -36,0 +36,0 @@ "devDependencies": {

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