feat: implement `KeyList.of()` and `KeyList.setThreshold()`
@@ -15,7 +15,7 @@ import java.util.List;
*/
public final class KeyList extends Key implements Collection<Key> {
@Nullable
- public final Integer threshold;
+ public Integer threshold;
private final List<Key> keys = new ArrayList<>();
@@ -30,6 +30,16 @@ public final class KeyList extends Key implements Collection<Key> {
this.threshold = threshold;
}
+ public static KeyList of(Key... keys) {
+ var list = new KeyList();
+
+ for (var key: keys) {
+ list.add(key);
+ }
+
+ return list;
+ }
+
/**
* Create a new key list where at least {@code threshold} keys must sign.
*
@@ -49,6 +59,27 @@ public final class KeyList extends Key implements Collection<Key> {
return keys;
}
+ /**
+ * Get the threshold for the KeyList.
+ *
+ * @return int
+ */
+ @Nullable
+ public Integer getThreshold() {
+ return threshold;
+ }
+
+ /**
+ * Set a threshold for the KeyList.
+ *
+ * @param threshold the minimum number of keys that must sign
+ * @return KeyList
+ */
+ public KeyList setThreshold(int threshold) {
+ this.threshold = threshold;
+ return this;
+ }
+
@Override
public int size() {
return keys.size();
