| 34 | } |
| 35 | |
| 36 | static const u8 *from_zbase32(const tal_t *ctx, const char *msg) |
| 37 | { |
| 38 | u5 *u5arr; |
| 39 | u8 *u8arr; |
| 40 | size_t len; |
| 41 | |
| 42 | u5arr = tal_arr(tmpctx, u5, strlen(msg)); |
| 43 | for (size_t i = 0; i < tal_bytelen(u5arr); i++) { |
| 44 | u5arr[i] = zbase32_revchars[(unsigned char)msg[i]]; |
| 45 | if (u5arr[i] > 31) |
| 46 | return NULL; |
| 47 | } |
| 48 | |
| 49 | u8arr = tal_arr(ctx, u8, (tal_bytelen(u5arr) * 5 + 7) / 8); |
| 50 | len = 0; |
| 51 | if (!bech32_convert_bits(u8arr, &len, 8, |
| 52 | u5arr, tal_bytelen(u5arr), 5, false)) |
| 53 | return tal_free(u8arr); |
| 54 | return len == tal_bytelen(u8arr) ? u8arr : tal_free(u8arr); |
| 55 | } |
| 56 | |
| 57 | static struct command_result *json_signmessage(struct command *cmd, |
| 58 | const char *buffer, |
no test coverage detected