legacy property

Transaction get legacy

Returns a non-witness variant of this transaction. Any witness inputs are replaced with their raw equivalents without witness data. If the transaction is already non-witness, then it shall be returned as-is.

Implementation

Transaction get legacy => isWitness
  ? _legacyCache ??= Transaction(
    version: version,
    inputs: inputs.map(
      // Raw inputs remove all witness data and are serialized as legacy
      // inputs. Don't waste creating a new object for non-witness inputs.
      (input) => input is WitnessInput
        ? RawInput(
          prevOut: input.prevOut,
          scriptSig: input.scriptSig,
          sequence: input.sequence,
        )
        : input,
    ),
    outputs: outputs,
    locktime: locktime,
  )
  : this;