mirror of
https://github.com/ok2/coinbin.git
synced 2026-04-24 11:44:02 +02:00
segwit spending bug fixes
This commit is contained in:
parent
ecb18acb0f
commit
c2ef949dd0
21
js/coin.js
21
js/coin.js
@ -792,7 +792,7 @@
|
|||||||
r.lock_time = 0;
|
r.lock_time = 0;
|
||||||
r.ins = [];
|
r.ins = [];
|
||||||
r.outs = [];
|
r.outs = [];
|
||||||
r.witness = [];
|
r.witness = false;
|
||||||
r.timestamp = null;
|
r.timestamp = null;
|
||||||
r.block = null;
|
r.block = null;
|
||||||
|
|
||||||
@ -1372,15 +1372,28 @@
|
|||||||
script.writeBytes(this.ins[index].script.chunks[0]);
|
script.writeBytes(this.ins[index].script.chunks[0]);
|
||||||
this.ins[index].script = script;
|
this.ins[index].script = script;
|
||||||
|
|
||||||
|
if(!coinjs.isArray(this.witness)){
|
||||||
|
this.witness = [];
|
||||||
|
}
|
||||||
|
|
||||||
this.witness.push([signature, wif2['pubkey']]);
|
this.witness.push([signature, wif2['pubkey']]);
|
||||||
|
|
||||||
/* reorder witness data */
|
/* attempt to reorder witness data as best as we can.
|
||||||
|
data can't be easily validated at this stage as
|
||||||
|
we dont have access to the inputs value and
|
||||||
|
making a web call will be too slow. */
|
||||||
|
|
||||||
var witness_order = [];
|
var witness_order = [];
|
||||||
|
var witness_used = [];
|
||||||
for(var i = 0; i < this.ins.length; i++){
|
for(var i = 0; i < this.ins.length; i++){
|
||||||
for(var y = 0; y < this.witness.length; y++){
|
for(var y = 0; y < this.witness.length; y++){
|
||||||
|
if(!witness_used.includes(y)){
|
||||||
var sw = coinjs.segwitAddress(this.witness[y][1]);
|
var sw = coinjs.segwitAddress(this.witness[y][1]);
|
||||||
if(sw['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])){
|
if(sw['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])){
|
||||||
witness_order.push(this.witness[y]);
|
witness_order.push(this.witness[y]);
|
||||||
|
witness_used.push(y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1424,7 +1437,7 @@
|
|||||||
var buffer = [];
|
var buffer = [];
|
||||||
buffer = buffer.concat(coinjs.numToBytes(parseInt(this.version),4));
|
buffer = buffer.concat(coinjs.numToBytes(parseInt(this.version),4));
|
||||||
|
|
||||||
if(this.witness.length>=1){
|
if(coinjs.isArray(this.witness)){
|
||||||
buffer = buffer.concat([0x00, 0x01]);
|
buffer = buffer.concat([0x00, 0x01]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1448,7 +1461,7 @@
|
|||||||
buffer = buffer.concat(scriptBytes);
|
buffer = buffer.concat(scriptBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.witness.length>=1){
|
if((coinjs.isArray(this.witness)) && this.witness.length>=1){
|
||||||
for(var i = 0; i < this.witness.length; i++){
|
for(var i = 0; i < this.witness.length; i++){
|
||||||
buffer = buffer.concat(coinjs.numToVarInt(this.witness[i].length));
|
buffer = buffer.concat(coinjs.numToVarInt(this.witness[i].length));
|
||||||
for(var x = 0; x < this.witness[i].length; x++){
|
for(var x = 0; x < this.witness[i].length; x++){
|
||||||
|
|||||||
4
sha1sum
4
sha1sum
@ -1,9 +1,9 @@
|
|||||||
---- Version 1.3 2017.09.20 ----
|
---- Version 1.3 2017.09.21 ----
|
||||||
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
|
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
|
||||||
3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js
|
3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js
|
||||||
253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js
|
253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js
|
||||||
3ac0e33ea28610e6f784658efcd88802bdd18119 ./js/coinbin.js
|
3ac0e33ea28610e6f784658efcd88802bdd18119 ./js/coinbin.js
|
||||||
466bd554f3466c477cd13bb355a4df343749b8b9 ./js/coin.js
|
494cefb8d6e59415ad25587de87a3dd1c055855e ./js/coin.js
|
||||||
988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js
|
988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js
|
||||||
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
|
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
|
||||||
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
|
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user