Fix endianess of checklocktimeverify
This commit is contained in:
parent
d53c236ec3
commit
cedc6dddaf
2 changed files with 9 additions and 9 deletions
14
js/coin.js
14
js/coin.js
|
@ -141,14 +141,14 @@
|
||||||
|
|
||||||
may throw a string on failure!
|
may throw a string on failure!
|
||||||
*/
|
*/
|
||||||
coinjs.simpleHodlAddress = function(pubkey, locktime) {
|
coinjs.simpleHodlAddress = function(pubkey, checklocktimeverify) {
|
||||||
|
|
||||||
if(locktime < 0) {
|
if(checklocktimeverify < 0) {
|
||||||
throw "Locktime is negative.";
|
throw "Parameter for OP_CHECKLOCKTIMEVERIFY is negative.";
|
||||||
}
|
}
|
||||||
|
|
||||||
var s = coinjs.script();
|
var s = coinjs.script();
|
||||||
s.writeBytes(Crypto.util.hexToBytes(locktime.toString(16)));
|
s.writeBytes(Crypto.util.hexToBytes(checklocktimeverify.toString(16)).reverse());
|
||||||
s.writeOp(177);//OP_CHECKLOCKTIMEVERIFY
|
s.writeOp(177);//OP_CHECKLOCKTIMEVERIFY
|
||||||
s.writeOp(117);//OP_DROP
|
s.writeOp(117);//OP_DROP
|
||||||
s.writeBytes(Crypto.util.hexToBytes(pubkey));
|
s.writeBytes(Crypto.util.hexToBytes(pubkey));
|
||||||
|
@ -681,11 +681,11 @@
|
||||||
r.address = multi['address'];
|
r.address = multi['address'];
|
||||||
r.type = 'multisig__'; // using __ for now to differentiat from the other object .type == "multisig"
|
r.type = 'multisig__'; // using __ for now to differentiat from the other object .type == "multisig"
|
||||||
} else if(s.chunks.length == 5 && s.chunks[1] == 177 && s.chunks[2] == 117 && s.chunks[4] == 172){
|
} else if(s.chunks.length == 5 && s.chunks[1] == 177 && s.chunks[2] == 117 && s.chunks[4] == 172){
|
||||||
// ^ <locktime> OP_CHECKLOCKTIMEVERIFY OP_DROP <pubkey> OP_CHECKSIG ^
|
// ^ <unlocktime> OP_CHECKLOCKTIMEVERIFY OP_DROP <pubkey> OP_CHECKSIG ^
|
||||||
r = {}
|
r = {}
|
||||||
r.pubkey = Crypto.util.bytesToHex(s.chunks[3]);
|
r.pubkey = Crypto.util.bytesToHex(s.chunks[3]);
|
||||||
r.locktime = parseInt(Crypto.util.bytesToHex(s.chunks[0]), 16); // TODO is this endian safe?
|
r.checklocktimeverify = parseInt(Crypto.util.bytesToHex(s.chunks[0].slice().reverse()), 16);
|
||||||
r.address = coinjs.simpleHodlAddress(r.pubkey, r.locktime).address;
|
r.address = coinjs.simpleHodlAddress(r.pubkey, r.checklocktimeverify).address;
|
||||||
r.type = "hodl__";
|
r.type = "hodl__";
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
|
@ -635,7 +635,7 @@ $(document).ready(function() {
|
||||||
if($("#redeemFromStatus").hasClass("hidden")) {
|
if($("#redeemFromStatus").hasClass("hidden")) {
|
||||||
// An ethical dilemma: Should we automatically set nLockTime?
|
// An ethical dilemma: Should we automatically set nLockTime?
|
||||||
if(redeem.from == 'redeemScript' && redeem.decodedRs.type == "hodl__") {
|
if(redeem.from == 'redeemScript' && redeem.decodedRs.type == "hodl__") {
|
||||||
$("#nLockTime").val(redeem.decodedRs.locktime);
|
$("#nLockTime").val(redeem.decodedRs.checklocktimeverify);
|
||||||
} else {
|
} else {
|
||||||
$("#nLockTime").val(0);
|
$("#nLockTime").val(0);
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ $(document).ready(function() {
|
||||||
var d = $("#verifyRsDataHodl .date").data("DateTimePicker");
|
var d = $("#verifyRsDataHodl .date").data("DateTimePicker");
|
||||||
$("#verifyRsDataHodl .address").val(decode['address']);
|
$("#verifyRsDataHodl .address").val(decode['address']);
|
||||||
$("#verifyRsDataHodl .pubkey").val(coinjs.pubkey2address(decode['pubkey']));
|
$("#verifyRsDataHodl .pubkey").val(coinjs.pubkey2address(decode['pubkey']));
|
||||||
$("#verifyRsDataHodl .date").val(decode['locktime'] >= 500000000? moment.unix(decode['locktime']).format("MM/DD/YYYY HH:mm") : decode['locktime']);
|
$("#verifyRsDataHodl .date").val(decode['checklocktimeverify'] >= 500000000? moment.unix(decode['checklocktimeverify']).format("MM/DD/YYYY HH:mm") : decode['checklocktimeverify']);
|
||||||
$("#verifyRsData").removeClass("hidden");
|
$("#verifyRsData").removeClass("hidden");
|
||||||
$("#verifyRsDataHodl").removeClass('hidden');
|
$("#verifyRsDataHodl").removeClass('hidden');
|
||||||
$(".verifyLink").attr('href','?verify='+$("#verifyScript").val());
|
$(".verifyLink").attr('href','?verify='+$("#verifyScript").val());
|
||||||
|
|
Loading…
Reference in a new issue