MCPcopy Create free account
hub / github.com/ElementsProject/lightning / hex_decode

Function hex_decode

ccan/ccan/str/hex/hex.c:24–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24bool hex_decode(const char *str, size_t slen, void *buf, size_t bufsize)
25{
26 unsigned char v1, v2;
27 unsigned char *p = buf;
28
29 while (slen > 1) {
30 if (!char_to_hex(&v1, str[0]) || !char_to_hex(&v2, str[1]))
31 return false;
32 if (!bufsize)
33 return false;
34 *(p++) = (v1 << 4) | v2;
35 str += 2;
36 slen -= 2;
37 bufsize--;
38 }
39 return slen == 0 && bufsize == 0;
40}
41
42static char hexchar(unsigned int val)
43{

Callers 15

privkeyFunction · 0.85
secret_eq_strFunction · 0.85
test_readFunction · 0.85
privkeyFunction · 0.85
secret_eq_strFunction · 0.85
test_readFunction · 0.85
get_chainhashFunction · 0.85
signature_from_hexFunction · 0.85
bitcoin_tx_from_hexFunction · 0.85
bitcoin_txid_from_hexFunction · 0.85
bitcoin_block_from_hexFunction · 0.85
pubkey_from_hexstrFunction · 0.85

Calls 1

char_to_hexFunction · 0.85

Tested by 15

privkeyFunction · 0.68
secret_eq_strFunction · 0.68
test_readFunction · 0.68
privkeyFunction · 0.68
secret_eq_strFunction · 0.68
test_readFunction · 0.68
get_chainhashFunction · 0.68
signature_from_hexFunction · 0.68
mainFunction · 0.68
secret_from_hexFunction · 0.68
fromhexFunction · 0.68
do_testFunction · 0.68