match static method

P2PKHInput? match(
  1. RawInput raw
)

Checks if the RawInput matches the expected format for a P2PKHInput, with or without a signature. If it does it returns a P2PKHInput for the input or else it returns null.

Implementation

static P2PKHInput? match(RawInput raw) {

  final script = raw.script;
  if (script == null) return null;
  final ops = script.ops;
  if (ops.isEmpty || ops.length > 2) return null;

  final insig = ops.length == 2 ? ops[0].ecdsaSig : null;
  if (insig == null && ops.length == 2) return null;

  final publicKey = ops.last.publicKey;
  if (publicKey == null) return null;

  return P2PKHInput(
    prevOut: raw.prevOut,
    publicKey: publicKey,
    insig: insig,
    sequence: raw.sequence,
  );

}