Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions plugins/lsps-plugin/src/proto/lsps2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use lsps_types::{
use serde::{Deserialize, Serialize};

pub mod failure_codes {
pub const TEMPORARY_CHANNEL_FAILURE: &'static str = "1007";
pub const UNKNOWN_NEXT_PEER: &'static str = "4010";
pub const TEMPORARY_CHANNEL_FAILURE: &'static str = "10070000";
pub const UNKNOWN_NEXT_PEER: &'static str = "400a";
}

pub trait ShortChannelIdJITExt {
Expand Down Expand Up @@ -206,4 +206,19 @@ mod tests {
let back: OpeningFeeParams = serde_json::from_str(&json).unwrap();
assert!(verify_promise(&back, SECRET));
}

#[test]
fn failure_codes_match_bolt4() {
use failure_codes::*;
// Failure code flags (BOLT 4): PERM = 0x4000, NODE = 0x2000,
// UPDATE = 0x1000.
// unknown_next_peer is PERM|10.
assert_eq!(UNKNOWN_NEXT_PEER, format!("{:04x}", 0x4000 | 10));
// temporary_channel_failure is UPDATE|7, followed by the u16 length
// of the channel_update, which we leave out (length 0).
assert_eq!(
TEMPORARY_CHANNEL_FAILURE,
format!("{:04x}{:04x}", 0x1000 | 7, 0)
);
}
}
Loading