@@ -436,6 +436,12 @@ macro_rules! offer_builder_test_methods { (
436
436
$return_value
437
437
}
438
438
439
+ #[ cfg_attr( c_bindings, allow( dead_code) ) ]
440
+ pub ( crate ) fn clear_signing_pubkey( $( $self_mut) * $self: $self_type) -> $return_type {
441
+ $self. offer. signing_pubkey = None ;
442
+ $return_value
443
+ }
444
+
439
445
#[ cfg_attr( c_bindings, allow( dead_code) ) ]
440
446
pub ( super ) fn build_unchecked( $self: $self_type) -> Offer {
441
447
$self. build_without_checks( )
@@ -1093,9 +1099,10 @@ impl TryFrom<OfferTlvStream> for OfferContents {
1093
1099
Some ( n) => Quantity :: Bounded ( NonZeroU64 :: new ( n) . unwrap ( ) ) ,
1094
1100
} ;
1095
1101
1096
- let signing_pubkey = match node_id {
1097
- None => return Err ( Bolt12SemanticError :: MissingSigningPubkey ) ,
1098
- Some ( node_id) => Some ( node_id) ,
1102
+ let ( signing_pubkey, paths) = match ( node_id, paths) {
1103
+ ( None , None ) => return Err ( Bolt12SemanticError :: MissingSigningPubkey ) ,
1104
+ ( _, Some ( paths) ) if paths. is_empty ( ) => return Err ( Bolt12SemanticError :: MissingPaths ) ,
1105
+ ( node_id, paths) => ( node_id, paths) ,
1099
1106
} ;
1100
1107
1101
1108
Ok ( OfferContents {
@@ -1662,12 +1669,31 @@ mod tests {
1662
1669
panic ! ( "error parsing offer: {:?}" , e) ;
1663
1670
}
1664
1671
1672
+ let offer = OfferBuilder :: new ( "foo" . into ( ) , pubkey ( 42 ) )
1673
+ . path ( BlindedPath {
1674
+ introduction_node : IntroductionNode :: NodeId ( pubkey ( 40 ) ) ,
1675
+ blinding_point : pubkey ( 41 ) ,
1676
+ blinded_hops : vec ! [
1677
+ BlindedHop { blinded_node_id: pubkey( 43 ) , encrypted_payload: vec![ 0 ; 43 ] } ,
1678
+ BlindedHop { blinded_node_id: pubkey( 44 ) , encrypted_payload: vec![ 0 ; 44 ] } ,
1679
+ ] ,
1680
+ } )
1681
+ . clear_signing_pubkey ( )
1682
+ . build ( )
1683
+ . unwrap ( ) ;
1684
+ if let Err ( e) = offer. to_string ( ) . parse :: < Offer > ( ) {
1685
+ panic ! ( "error parsing offer: {:?}" , e) ;
1686
+ }
1687
+
1665
1688
let mut builder = OfferBuilder :: new ( "foo" . into ( ) , pubkey ( 42 ) ) ;
1666
1689
builder. offer . paths = Some ( vec ! [ ] ) ;
1667
1690
1668
1691
let offer = builder. build ( ) . unwrap ( ) ;
1669
- if let Err ( e) = offer. to_string ( ) . parse :: < Offer > ( ) {
1670
- panic ! ( "error parsing offer: {:?}" , e) ;
1692
+ match offer. to_string ( ) . parse :: < Offer > ( ) {
1693
+ Ok ( _) => panic ! ( "expected error" ) ,
1694
+ Err ( e) => {
1695
+ assert_eq ! ( e, Bolt12ParseError :: InvalidSemantics ( Bolt12SemanticError :: MissingPaths ) ) ;
1696
+ } ,
1671
1697
}
1672
1698
}
1673
1699
0 commit comments