@ -3,6 +3,14 @@
# include <stdio.h>
# include <stdio.h>
# include <string.h>
# include <string.h>
void mk_short_channel_id ( struct short_channel_id * scid ,
u32 blocknum , u32 txnum , u16 outnum )
{
scid - > u64 = ( ( ( u64 ) blocknum & 0xFFFFFF ) < < 40 |
( ( u64 ) txnum & 0xFFFFFF ) < < 16 |
( outnum & 0xFFFF ) ) ;
}
bool short_channel_id_from_str ( const char * str , size_t strlen ,
bool short_channel_id_from_str ( const char * str , size_t strlen ,
struct short_channel_id * dst )
struct short_channel_id * dst )
{
{
@ -15,26 +23,14 @@ bool short_channel_id_from_str(const char *str, size_t strlen,
buf [ strlen ] = 0 ;
buf [ strlen ] = 0 ;
matches = sscanf ( buf , " %u:%u:%hu " , & blocknum , & txnum , & outnum ) ;
matches = sscanf ( buf , " %u:%u:%hu " , & blocknum , & txnum , & outnum ) ;
dst - > blocknum = blocknum ;
mk_short_channel_id ( dst , blocknum , txnum , outnum ) ;
dst - > txnum = txnum ;
dst - > outnum = outnum ;
return matches = = 3 ;
return matches = = 3 ;
}
}
char * short_channel_id_to_str ( const tal_t * ctx , const struct short_channel_id * scid )
char * short_channel_id_to_str ( const tal_t * ctx , const struct short_channel_id * scid )
{
{
return tal_fmt ( ctx , " %d:%d:%d " , scid - > blocknum , scid - > txnum , scid - > outnum ) ;
return tal_fmt ( ctx , " %d:%d:%d " ,
}
short_channel_id_blocknum ( scid ) ,
short_channel_id_txnum ( scid ) ,
bool short_channel_id_eq ( const struct short_channel_id * a ,
short_channel_id_outnum ( scid ) ) ;
const struct short_channel_id * b )
{
return a - > blocknum = = b - > blocknum & & a - > txnum = = b - > txnum & &
a - > outnum = = b - > outnum ;
}
u64 short_channel_id_to_uint ( const struct short_channel_id * scid )
{
return ( ( u64 ) scid - > blocknum & 0xFFFFFF ) < < 40 |
( ( u64 ) scid - > txnum & 0xFFFFFF ) < < 16 | ( scid - > outnum & 0xFFFF ) ;
}
}