From 74e53b49a59f8ddd0c7d6c7673c8769f5dd70ed9 Mon Sep 17 00:00:00 2001
From: Daniel Cousens <github@dcousens.com>
Date: Mon, 5 May 2014 13:05:16 +1000
Subject: [PATCH] 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.
---
 src/address.js     |  1 -
 src/script.js      | 36 ------------------------------------
 src/transaction.js | 34 ----------------------------------
 3 files changed, 71 deletions(-)

diff --git a/src/address.js b/src/address.js
index d1d7b82..5457e52 100644
--- a/src/address.js
+++ b/src/address.js
@@ -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 () {
diff --git a/src/script.js b/src/script.js
index 8f3cd2c..f550878 100644
--- a/src/script.js
+++ b/src/script.js
@@ -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()
diff --git a/src/transaction.js b/src/transaction.js
index 64bb41a..0b346a4 100644
--- a/src/transaction.js
+++ b/src/transaction.js
@@ -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