SegwitAddress constructor
SegwitAddress({})
Represents a Bitcoin segwit address
program
for segwit v0 this is the hash string representation of either the address;
it can be either a public key hash (P2WPKH) or the hash of the script (P2WSH)
for segwit v1 (aka taproot) this is the public key
Implementation
SegwitAddress(
{String? address,
String? program,
Script? script,
this.version = P2WPKH_ADDRESS_V0}) {
if (version == P2WPKH_ADDRESS_V0 || version == P2WSH_ADDRESS_V0) {
segwitNumVersion = 0;
} else if (version == P2TR_ADDRESS_V1) {
segwitNumVersion = 1;
} else {
throw ArgumentError('A valid segwit version is required.');
}
if (program != null) {
_program = program;
} else if (address != null) {
_program = _addressToHash(address);
} else if (script != null) {
_program = _scriptToHash(script);
}
}