projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Abide by max path length param in router.
[rust-lightning]
/
lightning-invoice
/
src
/
de.rs
diff --git
a/lightning-invoice/src/de.rs
b/lightning-invoice/src/de.rs
index 9284999b1884474a51a82a7637ce237fbf7fae65..381c7b645f9cc5ae765809f84a469e984c850ea4 100644
(file)
--- a/
lightning-invoice/src/de.rs
+++ b/
lightning-invoice/src/de.rs
@@
-1,5
+1,6
@@
#[cfg(feature = "std")]
use std::error;
#[cfg(feature = "std")]
use std::error;
+#[cfg(not(feature = "std"))]
use core::convert::TryFrom;
use core::fmt;
use core::fmt::{Display, Formatter};
use core::convert::TryFrom;
use core::fmt;
use core::fmt::{Display, Formatter};
@@
-14,7
+15,7
@@
use bitcoin::address::WitnessVersion;
use bitcoin::hashes::Hash;
use bitcoin::hashes::sha256;
use crate::prelude::*;
use bitcoin::hashes::Hash;
use bitcoin::hashes::sha256;
use crate::prelude::*;
-use lightning::ln::PaymentSecret;
+use lightning::ln::
types::
PaymentSecret;
use lightning::routing::gossip::RoutingFees;
use lightning::routing::router::{RouteHint, RouteHintHop};
use lightning::routing::gossip::RoutingFees;
use lightning::routing::router::{RouteHint, RouteHintHop};
@@
-42,7
+43,11
@@
mod hrp_sm {
}
impl States {
}
impl States {
- fn next_state(&self, read_symbol: char) -> Result<States, super::Bolt11ParseError> {
+ fn next_state(&self, read_byte: u8) -> Result<States, super::Bolt11ParseError> {
+ let read_symbol = match char::from_u32(read_byte.into()) {
+ Some(symb) if symb.is_ascii() => symb,
+ _ => return Err(super::Bolt11ParseError::MalformedHRP),
+ };
match *self {
States::Start => {
if read_symbol == 'l' {
match *self {
States::Start => {
if read_symbol == 'l' {
@@
-118,7
+123,7
@@
mod hrp_sm {
*range = Some(new_range);
}
*range = Some(new_range);
}
- fn step(&mut self, c:
char
) -> Result<(), super::Bolt11ParseError> {
+ fn step(&mut self, c:
u8
) -> Result<(), super::Bolt11ParseError> {
let next_state = self.state.next_state(c)?;
match next_state {
States::ParseCurrencyPrefix => {
let next_state = self.state.next_state(c)?;
match next_state {
States::ParseCurrencyPrefix => {
@@
-157,7
+162,7
@@
mod hrp_sm {
pub fn parse_hrp(input: &str) -> Result<(&str, &str, &str), super::Bolt11ParseError> {
let mut sm = StateMachine::new();
pub fn parse_hrp(input: &str) -> Result<(&str, &str, &str), super::Bolt11ParseError> {
let mut sm = StateMachine::new();
- for c in input.
char
s() {
+ for c in input.
byte
s() {
sm.step(c)?;
}
sm.step(c)?;
}