addInput method

int addInput(
  1. dynamic txHash,
  2. int vout, [
  3. int? sequence,
  4. Uint8List? prevOutScript,
])

Implementation

int addInput(dynamic txHash, int vout,
    [int? sequence, Uint8List? prevOutScript]) {
  if (!_canModifyInputs()) {
    throw ArgumentError('No, this would invalidate signatures');
  }
  Uint8List hash;
  var value;
  if (txHash is String) {
    hash = Uint8List.fromList(HEX.decode(txHash).reversed.toList());
  } else if (txHash is Uint8List) {
    hash = txHash;
  } else if (txHash is Transaction) {
    final txOut = txHash.outs[vout];
    prevOutScript = txOut.script;
    value = txOut.value;
    hash = txHash.getHash();
  } else {
    throw ArgumentError('txHash invalid');
  }
  return _addInputUnsafe(hash, vout,
      Input(sequence: sequence, prevOutScript: prevOutScript, value: value));
}