Merge pull request #53 from DanielWeigl/master
Error in serialization for nLockTime values
This commit is contained in:
commit
74a0fad4d2
1 changed files with 10 additions and 2 deletions
12
js/coin.js
12
js/coin.js
|
@ -148,7 +148,7 @@
|
|||
}
|
||||
|
||||
var s = coinjs.script();
|
||||
s.writeBytes(Crypto.util.hexToBytes(checklocktimeverify.toString(16)).reverse());
|
||||
s.writeBytes(coinjs.numToByteArray(checklocktimeverify).reverse());
|
||||
s.writeOp(177);//OP_CHECKLOCKTIMEVERIFY
|
||||
s.writeOp(117);//OP_DROP
|
||||
s.writeBytes(Crypto.util.hexToBytes(pubkey));
|
||||
|
@ -687,7 +687,7 @@
|
|||
// ^ <unlocktime> OP_CHECKLOCKTIMEVERIFY OP_DROP <pubkey> OP_CHECKSIG ^
|
||||
r = {}
|
||||
r.pubkey = Crypto.util.bytesToHex(s.chunks[3]);
|
||||
r.checklocktimeverify = parseInt(Crypto.util.bytesToHex(s.chunks[0].slice().reverse()), 16);
|
||||
r.checklocktimeverify = coinjs.bytesToNum(s.chunks[0].slice().reverse());
|
||||
r.address = coinjs.simpleHodlAddress(r.pubkey, r.checklocktimeverify).address;
|
||||
r.type = "hodl__";
|
||||
}
|
||||
|
@ -1454,6 +1454,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
coinjs.numToByteArray = function(num) {
|
||||
if (num <= 256) {
|
||||
return [num];
|
||||
} else {
|
||||
return [num % 256].concat(coinjs.numToByteArray(Math.floor(num / 256)));
|
||||
}
|
||||
}
|
||||
|
||||
coinjs.numToVarInt = function(num) {
|
||||
if (num < 253) {
|
||||
return [num];
|
||||
|
|
Loading…
Reference in a new issue