TransactionBuilder.fromTransaction constructor

TransactionBuilder.fromTransaction(
  1. Transaction transaction, [
  2. NetworkType? network
])

Implementation

factory TransactionBuilder.fromTransaction(Transaction transaction, [NetworkType? network]) {
  final txb = TransactionBuilder(network: network);

  txb.setVersion(transaction.version!);
  txb.setLockTime(transaction.locktime!);

  for (var txOut in transaction.outs) {
    txb.addOutput(txOut.script, txOut.value);
  }
  for (var txIn in transaction.ins) {
    txb._addInputUnsafe(txIn.hash!, txIn.index, Input(sequence: txIn.sequence, script: txIn.script, witness: txIn.witness));
  }

  return txb;
}