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

Function fromwire_keypair

wallet/psbt_fixup.c:72–97  ·  view source on GitHub ↗

BIP-0174: * := * := * := */

Source from the content-addressed store, hash-verified

70 * <value> := <valuelen> <valuedata>
71 */
72static struct keypair *fromwire_keypair(const tal_t *ctx,
73 const u8 **cursor,
74 size_t *max)
75{
76 struct keypair *kp = tal(ctx, struct keypair);
77 u64 len;
78 size_t keylen;
79
80 /* 0 byte terminates */
81 len = fromwire_compact_len(cursor, max);
82 if (len == 0)
83 return tal_free(kp);
84
85 kp->keytype = fromwire_compact_size(cursor, max);
86 /* Sanity check */
87 if (compact_size_len(kp->keytype) > len)
88 return tal_free(kp);
89 keylen = len - compact_size_len(kp->keytype);
90 kp->key = tal_arr(kp, u8, keylen);
91 fromwire_u8_array(cursor, max, kp->key, keylen);
92
93 len = fromwire_compact_len(cursor, max);
94 kp->value = tal_arr(kp, u8, len);
95 fromwire_u8_array(cursor, max, kp->value, len);
96 return kp;
97}
98
99static void towire_compact_size(u8 **pptr, u64 v)
100{

Callers 1

psbt_fixupFunction · 0.85

Calls 5

fromwire_compact_lenFunction · 0.85
tal_freeFunction · 0.85
fromwire_compact_sizeFunction · 0.85
compact_size_lenFunction · 0.85
fromwire_u8_arrayFunction · 0.50

Tested by

no test coverage detected