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

hubot-openassets

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hubot-openassets - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

4

package.json
{
"name": "hubot-openassets",
"version": "0.4.3",
"version": "0.5.0",
"description": "Hubot script for managing and sending assets based on the Open Assets protocol",

@@ -24,4 +24,6 @@ "main": "index.js",

"dependencies": {
"bs58": "3.0.0",
"bufferput": "0.1.1",
"strict-mode": "^0.4.2"
}
}

@@ -26,2 +26,6 @@ // Description:

var Base58 = require('bs58');
var Put = require('bufferput');
var crypto = require('crypto');
module.exports = function(robot) {

@@ -81,5 +85,6 @@

let content = this.getContent();
Object.keys(content).forEach(name => {
if (content[name] === address) { return name; }
});
let keys = Object.keys(content);
for (var i = 0; i< keys.length; i++) {
if (content[keys[i]] === address) { return keys[i]; }
}
}

@@ -145,2 +150,16 @@ };

function addressFromBitcoinAddress(btcAddress) {
function sha256(data) {
return new Buffer(crypto.createHash('sha256').update(data).digest('binary'), 'binary');
}
var btcAddr = new Buffer(Base58.decode(btcAddress));
var btcBuff = new Put()
.word8(19)
.put(btcAddr.slice(0, -4))
var btcCheck = sha256(sha256(btcBuff.buffer()));
btcBuff.put(btcCheck.slice(0,4))
return Base58.encode(btcBuff.buffer());
}
robot.hear(new RegExp(`${robotKeyword} show (.+)`, 'i'), function(hearResponse) {

@@ -164,8 +183,13 @@ balanceOf(hearResponse.match[1], function(assetDetails) {

}
var owners = JSON.parse(body).owners;
var total = owners.length > 10 ? 10 : owners.length;
for (var i=0; i<total; i++) {
var name = addressBook.lookupName(owners[i].address) || owners[i].address;
var asset = JSON.parse(body);
var owners = asset.owners;
var displayTotal = owners.length > 10 ? 10 : owners.length;
var totalAssets = 0;
owners.forEach(function(o) { totalAssets += parseInt(o.asset_quantity); });
for (var i=0; i<displayTotal; i++) {
var oaAddress = addressFromBitcoinAddress(owners[i].address);
var name = addressBook.lookupName(oaAddress) || oaAddress;
hearResponse.send(name + ': ' + owners[i].asset_quantity);
}
hearResponse.send(`${totalAssets} ${robotKeyword} total, owned by ${owners.length} addresses. details: https://www.coinprism.info/asset/${process.env.OA_ASSET_ID}/owners`);
});

@@ -247,4 +271,11 @@ });

.auth(process.env.OA_SERVER_USERNAME, process.env.OA_SERVER_PASSWORD)
.query(params).post()(cb);
.query(params).post()(function(err, res, body) {
if(err || res.statusCode !== 200) {
console.log("sending assets failed");
}
console.log(body);
cb(err, res, body);
});
}
};
var Base58 = require('bs58');
var BufferPut = require('bufferput');
var Put = require('bufferput');
var crypto = require('crypto');
var buffertools = require('buffertools')
var BufferPut = require('bufferput');

@@ -14,12 +11,12 @@ function sha256(data) {

function addressFromBitcoinAddress(btcAddress) {
var btcAddr = Base58.decode(btcAddress);
var btcAddr = new Buffer(Base58.decode(btcAddress));
var btcBuff = new Put()
.word8(19)
.put(btcAddr.slice(0, -4));
console.log(btcBuff.buffer());
var btcCheck = sha256(btcBuff.buffer())
.put(btcAddr.slice(0, -4))
var btcCheck = sha256(sha256(btcBuff.buffer()));
btcBuff.put(btcCheck.slice(0,4))
return Base58.encode(btcBuff.buffer());
}
console.log(addressFromBitcoinAddress('18mkjg6pRdJg1SEkj4riwaBs19kU4URtC9'));
console.log(addressFromBitcoinAddress('12ukurZsDMtSSJ1Qad59LiFqVM8YQnbTen'));
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