buildByType function
Implementation
PaymentData? buildByType(String? type, Input input, bool allowIncomplete, NetworkType? network) {
if (type == SCRIPT_TYPES['P2PKH']) {
return P2PKH(data: PaymentData(pubkey: input.pubkeys![0], signature: input.signatures![0]), network: network).data;
} else if (type == SCRIPT_TYPES['P2WPKH']) {
return P2WPKH(data: PaymentData(pubkey: input.pubkeys![0], signature: input.signatures![0]), network: network).data;
} else if (type == SCRIPT_TYPES['P2SH']) {
final redeem = buildByType(input.redeemScriptType, input, allowIncomplete, network);
if (redeem == null) {
return null;
}
return P2SH(
data: PaymentData(
redeem: PaymentData(
output: redeem.output ?? input.redeemScript,
input: redeem.input,
witness: redeem.witness,
)),
network: network)
.data;
}
return null;
}