All files / lib/deserialize channel-settings-from-message.ts

100% Statements 12/12
50% Branches 4/8
100% Functions 1/1
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  1x           1x 2x 2x 2x 2x 2x 2x 2x 2x     2x 2x    
import { ChannelUpdateMessage } from "@node-lightning/wire";
import { ChannelSettings } from "../channel-settings";
 
/**
 * Creates channels settings from an update message
 * @param msg
 */
export function channelSettingsFromMessage(msg: ChannelUpdateMessage): ChannelSettings {
    const instance = new ChannelSettings();
    instance.direction = msg.direction;
    instance.timestamp = msg.timestamp;
    instance.cltvExpiryDelta = msg.cltvExpiryDelta;
    instance.htlcMinimumMsat = msg.htlcMinimumMsat ? msg.htlcMinimumMsat.msats : undefined;
    instance.htlcMaximumMsat = msg.htlcMaximumMsat ? msg.htlcMaximumMsat.msats : undefined;
    instance.feeBaseMsat = msg.feeBaseMsat ? Number(msg.feeBaseMsat.msats) : undefined;
    instance.feeProportionalMillionths = msg.feeProportionalMillionths
        ? Number(msg.feeProportionalMillionths.microsats)
        : null;
    instance.disabled = msg.disabled;
    return instance;
}