// baseline estimates, used to improve performance
const TX_EMPTY_SIZE = 4 + 1 + 1 + 4
const TX_INPUT_BASE = 32 + 4 + 1 + 4
const TX_INPUT_PUBKEYHASH = 106
const TX_OUTPUT_BASE = 8 + 1
const TX_OUTPUT_PUBKEYHASH = 25

function inputBytes (input) {
  return TX_INPUT_BASE + (input.script ? input.script.length : TX_INPUT_PUBKEYHASH)
}

function outputBytes (output) {
  return TX_OUTPUT_BASE + (output.script ? output.script.length : TX_OUTPUT_PUBKEYHASH)
}

function dustThreshold (output, feeRate) {
  return 3 * (outputBytes(output) * feeRate)
}

function transactionBytes (inputs, outputs) {
  return TX_EMPTY_SIZE +
    inputs.reduce((a, x) => a + inputBytes(x), 0) +
    outputs.reduce((a, x) => a + outputBytes(x), 0)
}

module.exports = {
  dustThreshold,
  inputBytes,
  outputBytes,
  transactionBytes
}

@@ -232,21 +232,16 @@
 tBytes (
-input
 ) %7B%0A  re
@@ -264,46 +264,8 @@
 SE +
- (input.script ? input.script.length :
  TX_
@@ -272,33 +272,32 @@
 INPUT_PUBKEYHASH
-)
 %0A%7D%0A%0Afunction out

drop input.script support, useless