Skip to content

Instantly share code, notes, and snippets.

@tomotomo9696
Created May 5, 2018 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomotomo9696/ed53f9cd65369846445c424a2f64ba77 to your computer and use it in GitHub Desktop.
Save tomotomo9696/ed53f9cd65369846445c424a2f64ba77 to your computer and use it in GitHub Desktop.
<!--
insight-ui-bitzeny/public/views/block.html
<tr>
<td><strong>Merkle Root</strong></td>
<td class="text-right text-muted">
<div class="ellipsis">
<span class="btn-copy" clip-copy="block.merkleroot"></span>
<span>{{block.merkleroot}}</span>
</div>
</td>
</tr>
Please add the following code after this.
-->
<tr data-ng-show="block.segwitCommitment">
<td><strong>Segwit Commitment</strong></td>
<td class="text-right text-muted">
<div class="ellipsis">
<span class="btn-copy" clip-copy="block.segwitCommitment"></span>
<span>{{block.segwitCommitment}}</span>
</div>
</td>
</tr>
// insight-api-bitzeny/app/controllers/blocks.js
// Please change line 19 - 23 to this
// https://github.com/BitzenyCoreDevelopers/insight-api-bitzeny/blob/master/app/controllers/blocks.js#L19-L23
tdb.getPoolInfo(block.info.tx[0], function(info) {
block.info.poolInfo = info;
tdb.getSegwitCommitment(block.info.tx[0], function(info) {
block.info.segwitCommitment = info;
req.block = block.info;
return next();
});
});
// Please change line 69 - 72 to this
// https://github.com/BitzenyCoreDevelopers/insight-api-bitzeny/blob/master/app/controllers/blocks.js#L69-L72
tdb.getPoolInfo(block.info.tx[0], function(info) {
block.info.poolInfo = info;
tdb.getSegwitCommitment(block.info.tx[0], function(info) {
block.info.segwitCommitment = info;
return cb(err, block.info);
});
});
// Please add to insight-api-bitzeny/lib/TransactionDb.js
TransactionDb.prototype.getSegwitCommitment = function(txid, cb) {
Rpc.getTxInfo(txid, function(err, txInfo) {
if (err) return cb(false);
var ret;
if (txInfo && txInfo.isCoinBase) {
txInfo.vout.forEach( function(v) {
if (v.scriptPubKey.type === "nulldata") {
var data = v.scriptPubKey.hex.match(/.{1,2}/g).map(function(v){return parseInt(v, 16)});
var i = data.indexOf(106);
if(i !== -1){
data = data.slice(i+1);
if(data[0] === 36){
var hex = Array.prototype.map.call(data.slice(1), function(x){return ('00' + x.toString(16)).slice(-2)}).join('');
if(hex.indexOf("aa21a9ed") === 0){
ret = hex.slice(8, 32*2+8)
}
}
}
}
});
}
return cb(ret);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment