diff --git a/nitro/signedstate.nim b/nitro/signedstate.nim index 0c0db0a..cd8e63d 100644 --- a/nitro/signedstate.nim +++ b/nitro/signedstate.nim @@ -8,12 +8,12 @@ type state*: State signatures*: seq[(EthAddress, Signature)] -func participants*(signed: SignedState): seq[EthAddress] = - signed.state.channel.participants +func hasParticipant*(signed: SignedState, participant: EthAddress): bool = + signed.state.channel.participants.contains(participant) func verifySignatures*(signed: SignedState): bool = for (participant, signature) in signed.signatures: - if not signed.participants.contains(participant): + if not signed.hasParticipant(participant): return false if not signature.verify(signed.state, participant): return false diff --git a/nitro/wallet.nim b/nitro/wallet.nim index 6ccd9be..27bdd60 100644 --- a/nitro/wallet.nim +++ b/nitro/wallet.nim @@ -46,11 +46,11 @@ func openLedgerChannel*(wallet: var Wallet, let state = startLedger(wallet.address, hub, chainId, nonce, asset, amount) wallet.createChannel(state) -func acceptChannel*(wallet: var Wallet, state: SignedState): ?!ChannelId = - if not state.participants.contains(wallet.address): +func acceptChannel*(wallet: var Wallet, signed: SignedState): ?!ChannelId = + if not signed.hasParticipant(wallet.address): return ChannelId.failure "wallet owner is not a participant" - if not verifySignatures(state): + if not verifySignatures(signed): return ChannelId.failure "incorrect signatures" - wallet.createChannel(state).success + wallet.createChannel(signed).success