feat: update `Transaction.getSignatures()` to return `Map<AccountId, Map<PublicKey, byte[]>>`
@@ -480,19 +480,24 @@ public abstract class Transaction<T extends Transaction<T>>
return (T) this;
}
- public Map<PublicKey, byte[]> getSignatures() {
- var map = new HashMap<PublicKey, byte[]>();
+ public Map<AccountId, Map<PublicKey, byte[]>> getSignatures() {
+ var map = new HashMap<AccountId, Map<PublicKey, byte[]>>(nodeIds.size());
if (signatures.size() == 0) {
return map;
}
- for (var sigPair : signatures.get(0).getSigPairList()) {
- map.put(
+ for (int i = 0; i < nodeIds.size(); i++) {
+ var sigMap = signatures.get(i);
+ var nodeAccountId = nodeIds.get(i);
+ var keyMap = map.computeIfAbsent(nodeAccountId, k -> new HashMap<>(sigMap.getSigPairCount()));
+ for (var sigPair : sigMap.getSigPairList()) {
+ keyMap.put(
PublicKey.fromBytes(sigPair.getPubKeyPrefix().toByteArray()),
sigPair.getEd25519().toByteArray()
);
}
+ }
return map;
}
