nim-nitro/nitro/protocol/channel.nim
Mark Spanbroek 63b9b5452f Rename: Channel -> ChannelDefinition
To avoid name clash with upcoming channel abstraction
in the wallet.
2021-03-09 12:41:51 +01:00

23 lines
500 B
Nim

import pkg/nimcrypto
import ../basics
import ./abi
include questionable/errorban
export basics
type
ChannelDefinition* = object
nonce*: UInt48
participants*: seq[EthAddress]
chainId*: UInt256
proc getChannelId*(channel: ChannelDefinition): array[32, byte] =
var encoder= AbiEncoder.init()
encoder.startTuple()
encoder.write(channel.chainId)
encoder.write(channel.participants)
encoder.write(channel.nonce)
encoder.finishTuple()
keccak256.digest(encoder.finish()).data