BipAddress constructor

BipAddress({
  1. String? address,
  2. String? hash160,
  3. Script? script,
})

Represents a Bitcoin address

hash160 the hash160 string representation of the address; hash160 represents two consequtive hashes of the public key or the redeam script, first a SHA-256 and then an RIPEMD-160

Implementation

BipAddress({String? address, String? hash160, Script? script}) {
  if (hash160 != null) {
    if (!isValidHash160(hash160)) {
      throw Exception("Invalid value for parameter hash160.");
    }
    _h160 = hash160;
  } else if (address != null) {
    if (!isValidAddress(address)) {
      throw ArgumentError("Invalid addres");
    }
    _h160 = _addressToHash160(address);
  } else if (script != null) {
    _h160 = _scriptToHash160(script);
  } else {
    if (type == AddressType.p2pk) return;
    throw ArgumentError("Invalid parameters");
  }
}