| 4 | #include <common/utils.h> |
| 5 | |
| 6 | bool 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 | |
| 37 | bool psbt_add_keypath_to_last_output(struct bitcoin_tx *tx, |
| 38 | u32 key_index, |
no test coverage detected