publicKeyForAddress method
Public key from the credential's walletAdditionalAddresses, used to construct a PSBT.
Implementation
@override
String publicKeyForAddress(String address) {
String instrumentationOperation() {
final user = _state.user;
if (user == null) {
throw DynamicStateException("not authenticated — sign in first");
}
final matches = user.verifiedCredentials.map((credential) => (credential.walletAdditionalAddresses == null ? null : firstWhereOrNull<WalletAdditionalAddress>(credential.walletAdditionalAddresses!, (item) => item.address == address))?.publicKey).where((v) => v != null).map((v) => v!).toList();
final publicKey = firstOrNull(matches);
if (publicKey == null) {
throw DynamicStateException("no public key on record for that Bitcoin address — walletAdditionalAddresses is missing or empty on this credential");
}
return publicKey;
}
return _api.instrumentation.run("btc.publicKeyForAddress", instrumentationOperation);
}