Created
May 5, 2018 19:30
-
-
Save tomotomo9696/ed53f9cd65369846445c424a2f64ba77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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