add sorting of pubkeys for multisig addr generation
This commit is contained in:
parent
710be7b147
commit
921bc2ff17
23
Script.js
23
Script.js
@ -420,7 +420,28 @@ Script.createPubKeyHashOut = function(pubKeyHash) {
|
|||||||
return script;
|
return script;
|
||||||
};
|
};
|
||||||
|
|
||||||
Script.createMultisig = function(n_required, keys) {
|
Script._sortKeys = function(keys) {
|
||||||
|
return keys.sort(function(buf1, buf2) {
|
||||||
|
var len = buf1.length > buf1.length ? buf1.length : buf2.length;
|
||||||
|
for (var i = 0; i <= len; i++) {
|
||||||
|
if (buf1[i] === undefined)
|
||||||
|
return -1; //shorter strings come first
|
||||||
|
if (buf2[i] === undefined)
|
||||||
|
return 1;
|
||||||
|
if (buf1[i] < buf2[i])
|
||||||
|
return -1;
|
||||||
|
if (buf1[i] > buf2[i])
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Script.createMultisig = function(n_required, inKeys, opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
var keys = opts.noSorting ? i || inKeys : this._sortKeys(inKeys);
|
||||||
var script = new Script();
|
var script = new Script();
|
||||||
script.writeN(n_required);
|
script.writeN(n_required);
|
||||||
keys.forEach(function(key) {
|
keys.forEach(function(key) {
|
||||||
|
|||||||
@ -68,7 +68,7 @@
|
|||||||
],
|
],
|
||||||
"unspentP2sh": [
|
"unspentP2sh": [
|
||||||
{
|
{
|
||||||
"address": "2Mwswt6Eih28xH8611fexpqKqJCLJMomveK",
|
"address": "2NDJbzwzsmRgD2o5HHXPhuq5g6tkKTjYkd6",
|
||||||
"scriptPubKey": "a91432d272ce8a9b482b363408a0b1dd28123d59c63387",
|
"scriptPubKey": "a91432d272ce8a9b482b363408a0b1dd28123d59c63387",
|
||||||
"txid": "2ac165fa7a3a2b535d106a0041c7568d03b531e58aeccdd3199d7289ab12cfc1",
|
"txid": "2ac165fa7a3a2b535d106a0041c7568d03b531e58aeccdd3199d7289ab12cfc1",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user