Script/Transaction: remove untested functions
These functions are not under test, and are unnecessary bloat due to a confusing API. Script.from*(asmStr) were two functions that attempted to parse ASM codes and produce a script from this. While useful, an parser can be introduced later under a single function and under test... removed. Although Script.extractPublicKeys implementation is likely to be correct, it is not absolute in that what it returns is even strictly a set of public keys. It is a useful function, but can be done in a better way later, probably checking against the Script templates instead. Transaction.signWithKeys has some inherent undocumented behaviour, and it is not clear when you would use it over just Transaction.addOutput and Transaction.sign individually. Nor does it mimic anything in the bitcoind API... removed.
This commit is contained in:
parent
76323a07d0
commit
74e53b49a5
3 changed files with 0 additions and 71 deletions
|
@ -16,7 +16,6 @@ Address.fromBase58Check = function(string) {
|
|||
|
||||
return new Address(decode.payload, decode.version)
|
||||
}
|
||||
Address.prototype.fromString = Address.prototype.fromBase58Check
|
||||
|
||||
// Export functions
|
||||
Address.prototype.toBase58Check = function () {
|
||||
|
|
|
@ -23,32 +23,6 @@ Script.fromHex = function(hex) {
|
|||
return Script.fromBuffer(new Buffer(hex, 'hex'))
|
||||
}
|
||||
|
||||
Script.fromPubKey = function(str) {
|
||||
var script = new Script()
|
||||
var s = str.split(' ')
|
||||
for (var i in s) {
|
||||
if (Opcode.map.hasOwnProperty(s[i])) {
|
||||
script.writeOp(Opcode.map[s[i]])
|
||||
} else {
|
||||
script.writeBytes(convert.hexToBytes(s[i]))
|
||||
}
|
||||
}
|
||||
return script
|
||||
}
|
||||
|
||||
Script.fromScriptSig = function(str) {
|
||||
var script = new Script()
|
||||
var s = str.split(' ')
|
||||
for (var i in s) {
|
||||
if (Opcode.map.hasOwnProperty(s[i])) {
|
||||
script.writeOp(Opcode.map[s[i]])
|
||||
} else {
|
||||
script.writeBytes(convert.hexToBytes(s[i]))
|
||||
}
|
||||
}
|
||||
return script
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the parsed script representation.
|
||||
*
|
||||
|
@ -399,16 +373,6 @@ Script.createOutputScript = function(address, network) {
|
|||
return script
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract pubkeys from a multisig script
|
||||
*/
|
||||
|
||||
Script.prototype.extractPubkeys = function() {
|
||||
return this.chunks.filter(function(chunk) {
|
||||
return(chunk[0] == 4 && chunk.length == 65 || chunk[0] < 4 && chunk.length == 33)
|
||||
})
|
||||
}
|
||||
|
||||
// m [pubKeys ...] n OP_CHECKMULTISIG
|
||||
Script.createMultisigOutputScript = function(m, pubKeys) {
|
||||
var script = new Script()
|
||||
|
|
|
@ -380,40 +380,6 @@ Transaction.prototype.sign = function(index, key, type, network) {
|
|||
this.setScriptSig(index, scriptSig)
|
||||
}
|
||||
|
||||
// Takes outputs of the form [{ output: 'txhash:index', address: 'address' },...]
|
||||
Transaction.prototype.signWithKeys = function(keys, outputs, type) {
|
||||
type = type || SIGHASH_ALL
|
||||
|
||||
var addrdata = keys.map(function(key) {
|
||||
assert(key instanceof ECKey)
|
||||
|
||||
return {
|
||||
key: key,
|
||||
address: key.getAddress().toString()
|
||||
}
|
||||
})
|
||||
|
||||
var hmap = {}
|
||||
outputs.forEach(function(o) {
|
||||
hmap[o.output] = o
|
||||
})
|
||||
|
||||
for (var i = 0; i < this.ins.length; i++) {
|
||||
var outpoint = this.ins[i].outpoint.hash + ':' + this.ins[i].outpoint.index
|
||||
var histItem = hmap[outpoint]
|
||||
|
||||
if (!histItem) continue;
|
||||
|
||||
var thisInputAddrdata = addrdata.filter(function(a) {
|
||||
return a.address == histItem.address
|
||||
})
|
||||
|
||||
if (thisInputAddrdata.length === 0) continue;
|
||||
|
||||
this.sign(i,thisInputAddrdata[0].key)
|
||||
}
|
||||
}
|
||||
|
||||
Transaction.prototype.signScriptSig = function(index, script, key, type) {
|
||||
type = type || SIGHASH_ALL
|
||||
|
||||
|
|
Loading…
Reference in a new issue