common/bech32_util: simple routines for checksumless bech32 charset usage.

Offers don't use the checksum, as they're signed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-12-05 12:54:54 +10:30
parent f06ad0471c
commit d3ef871833
2 changed files with 115 additions and 1 deletions

View File

@@ -3,11 +3,28 @@
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include <common/hash_u5.h>
#include <stdbool.h>
/**
* Push the bytes in src in 5 bit format onto the end of data.
*/
void bech32_push_bits(u5 **data, const void *src, size_t nbits);
/**
* Push the bytes in src in 8 bit format onto the end of data.
*/
void bech32_pull_bits(u8 **data, const u5 *src, size_t nbits);
/**
* Checksumless bech32 routines.
*/
bool from_bech32_charset(const tal_t *ctx,
const char *bech32, size_t bech32_len,
char **hrp, u8 **data);
char *to_bech32_charset(const tal_t *ctx,
const char *hrp, const u8 *data);
#endif /* LIGHTNING_COMMON_BECH32_UTIL_H */