signNodeValue function
Future<SignNodeValueReturnType>
signNodeValue(
- TTNode node,
- String key,
- PairReturnType pair, [
- String? encoding,
Implementation
Future<SignNodeValueReturnType> signNodeValue(
TTNode node, String key, PairReturnType pair,
[String? encoding]) async {
encoding ??= DEFAULT_OPTS.encode;
final data = node[key];
final json = parse(data);
if (data != null &&
json != null &&
json is Map<String, dynamic> &&
((json.containsKey('s') && json.containsKey('m')) ||
(json.containsKey(':') && json.containsKey('~')))) {
// already signed
return SignNodeValueReturnType.fromJson(json);
}
final hash = await hashNodeKey(node, key);
// final hash = await hashForSignature(json);
final sig = await signHash(hash, pair);
return SignNodeValueReturnType.fromJson({':': json, '~': sig});
}