addAuthorizedKey method Null safety
- dynamic publicKey,
- dynamic encryptedSecretKey
Add an authorized public key for secret decryption to the transaction with its encrypted secret key @param {String | Uint8List} publicKey Authorized public key (hexadecimal or or binary buffer) @param {String | Uint8List} encryptedSecretKey Encrypted secret key for the given public key (hexadecimal or binary buffer)
Implementation
TransactionBuilder addAuthorizedKey(publicKey, encryptedSecretKey) {
if (!(publicKey is Uint8List) && !(publicKey is String)) {
throw "'publicKey' must be a string or Uint8List";
}
if (!(encryptedSecretKey is Uint8List) && !(encryptedSecretKey is String)) {
throw "'encryptedSecretKey' must be a string or Uint8List";
}
if (publicKey is String) {
if (isHex(publicKey)) {
publicKey = hexToUint8List(publicKey);
} else {
throw "'publicKey' must be an hexadecimal string";
}
}
if (encryptedSecretKey is String) {
if (isHex(encryptedSecretKey)) {
encryptedSecretKey = hexToUint8List(encryptedSecretKey);
} else {
throw "'encryptedSecretKey' must be an hexadecimal string";
}
}
data!.keys!.authorizedKeys!
.putIfAbsent(uint8ListToHex(publicKey), () => encryptedSecretKey);
return this;
}