"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChannelId = exports.isExternalDestination = void 0;
var ethers_1 = require("ethers");
function isExternalDestination(bytes32) {
    return /^0x(0{24})([a-fA-F0-9]{40})$/.test(bytes32);
}
exports.isExternalDestination = isExternalDestination;
function getChannelId(channel) {
    var chainId = channel.chainId, participants = channel.participants, channelNonce = channel.channelNonce;
    var channelId = ethers_1.utils.keccak256(ethers_1.utils.defaultAbiCoder.encode(['uint256', 'address[]', 'uint256'], [chainId, participants, channelNonce]));
    if (isExternalDestination(channelId))
        throw Error('This channel would have an external destination as an id');
    return channelId;
}
exports.getChannelId = getChannelId;
//# sourceMappingURL=channel.js.map