mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-18 12:34:21 +01:00
common: rename bech32_encode parameter
s/max_input_len/max_output_len This maximum length applies to the output parameter, not the data parameter. Thus it is more intuitive to name it max_output_len.
This commit is contained in:
committed by
Rusty Russell
parent
eec30b1847
commit
513bd29330
@@ -55,7 +55,7 @@ const int8_t bech32_charset_rev[128] = {
|
||||
1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
int bech32_encode(char *output, const char *hrp, const uint8_t *data, size_t data_len, size_t max_input_len, bech32_encoding enc) {
|
||||
int bech32_encode(char *output, const char *hrp, const uint8_t *data, size_t data_len, size_t max_output_len, bech32_encoding enc) {
|
||||
uint32_t chk = 1;
|
||||
size_t i = 0;
|
||||
while (hrp[i] != 0) {
|
||||
@@ -68,7 +68,7 @@ int bech32_encode(char *output, const char *hrp, const uint8_t *data, size_t dat
|
||||
chk = bech32_polymod_step(chk) ^ (ch >> 5);
|
||||
++i;
|
||||
}
|
||||
if (i + 7 + data_len > max_input_len) return 0;
|
||||
if (i + 7 + data_len > max_output_len) return 0;
|
||||
chk = bech32_polymod_step(chk);
|
||||
while (*hrp != 0) {
|
||||
chk = bech32_polymod_step(chk) ^ (*hrp & 0x1f);
|
||||
|
||||
@@ -83,7 +83,7 @@ typedef enum {
|
||||
* In: hrp : Pointer to the null-terminated human readable part.
|
||||
* data : Pointer to an array of 5-bit values.
|
||||
* data_len: Length of the data array.
|
||||
* max_input_len: Maximum valid length of input (90 for segwit usage).
|
||||
* max_output_len: Maximum valid length of output (90 for segwit usage).
|
||||
* enc: Which encoding to use (BECH32_ENCODING_BECH32{,M}).
|
||||
* Returns 1 if successful.
|
||||
*/
|
||||
@@ -92,7 +92,7 @@ int bech32_encode(
|
||||
const char *hrp,
|
||||
const uint8_t *data,
|
||||
size_t data_len,
|
||||
size_t max_input_len,
|
||||
size_t max_output_len,
|
||||
bech32_encoding enc
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user