Skip to content

Commit

Permalink
Make it possible to manually construct a ThresholdKey
Browse files Browse the repository at this point in the history
  • Loading branch information
qtbeee committed Nov 6, 2019
1 parent ebb7386 commit 62a272e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Sources/Hedera/crypto/ThresholdKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ public final class ThresholdKey: PublicKey {
let threshold: UInt32
var keys: [PublicKey]

init(threshold: UInt32, keys: [PublicKey] = []) {
self.threshold = threshold
self.keys = keys
super.init()
}

required init?(_ proto: Proto_Key) {
guard proto.thresholdKey.hasKeys else { return nil }
threshold = proto.thresholdKey.threshold
Expand All @@ -27,4 +33,16 @@ public final class ThresholdKey: PublicKey {

return proto
}

@discardableResult
public func addKey(_ key: PublicKey) -> Self {
keys.append(key)
return self
}

@discardableResult
public func addKeys(_ keys: [PublicKey]) -> Self {
self.keys.append(contentsOf: keys)
return self
}
}

0 comments on commit 62a272e

Please sign in to comment.