p2wpkhScriptCode method

  1. @protected
Uint8List p2wpkhScriptCode(
  1. AssemblerInput meta
)

BIP-143 scriptCode for P2WPKH / nested P2WPKH: OP_DUP OP_HASH160 <20-byte keyhash> OP_EQUALVERIFY OP_CHECKSIG.

Implementation

@protected
Uint8List p2wpkhScriptCode(AssemblerInput meta) {
  final pubKey = meta.publicKey;
  if (pubKey == null) {
    throw ArgumentError(
      'AssemblerInput.publicKey is required for type ${meta.type}',
    );
  }
  final keyHash = hash160(pubKey);
  return Uint8List.fromList([
    0x76, // OP_DUP
    0xa9, // OP_HASH160
    0x14, // push 20 bytes
    ...keyHash,
    0x88, // OP_EQUALVERIFY
    0xac, // OP_CHECKSIG
  ]);
}