expandOutput static method
Implementation
static Output? expandOutput(Uint8List script, [Uint8List? ourPubKey]) {
if (ourPubKey == null) return new Output();
var type = classifyOutput(script);
if (type == SCRIPT_TYPES['P2WPKH']) {
Uint8List wpkh1 = P2WPKH(data: PaymentData(output: script)).data.hash!;
Uint8List wpkh2 = bcrypto.hash160(ourPubKey);
if (wpkh1 != wpkh2) throw ArgumentError('Hash mismatch!');
return new Output(pubkeys: [ourPubKey], signatures: [null]);
} else if (type == SCRIPT_TYPES['P2PKH']) {
Uint8List pkh1 = P2PKH(data: new PaymentData(output: script)).data.hash!;
Uint8List pkh2 = bcrypto.hash160(ourPubKey);
if (pkh1 != pkh2) throw ArgumentError('Hash mismatch!');
return new Output(pubkeys: [ourPubKey], signatures: [null]);
}
}