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

Function psbt_output_set_keypath

common/psbt_keypath.c:6–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <common/utils.h>
5
6bool psbt_output_set_keypath(u32 index,
7 const struct ext_key *ext,
8 bool is_taproot,
9 struct wally_psbt_output *output)
10{
11 u8 fingerprint[BIP32_KEY_FINGERPRINT_LEN];
12 if (bip32_key_get_fingerprint(
13 (struct ext_key *) ext, fingerprint, sizeof(fingerprint)) != WALLY_OK)
14 abort();
15
16 u32 path[1];
17 path[0] = index;
18
19 if (is_taproot) {
20 if (wally_psbt_output_taproot_keypath_add(output,
21 ext->pub_key + 1, sizeof(ext->pub_key) - 1,
22 NULL, 0,
23 fingerprint, sizeof(fingerprint),
24 path, 1) != WALLY_OK)
25 return false;
26 } else {
27 if (wally_psbt_output_keypath_add(output,
28 ext->pub_key, sizeof(ext->pub_key),
29 fingerprint, sizeof(fingerprint),
30 path, 1) != WALLY_OK)
31 return false;
32 }
33
34 return true;
35}
36
37bool psbt_add_keypath_to_last_output(struct bitcoin_tx *tx,
38 u32 key_index,

Callers 2

Calls 1

abortFunction · 0.85

Tested by

no test coverage detected