| 299 | } |
| 300 | |
| 301 | void psbt_input_add_pubkey(struct wally_psbt *psbt, size_t in, |
| 302 | const struct pubkey *pubkey, bool is_taproot) |
| 303 | { |
| 304 | int wally_err; |
| 305 | u32 empty_path[1] = {0}; |
| 306 | unsigned char fingerprint[4]; |
| 307 | struct ripemd160 hash; |
| 308 | u8 pk_der[PUBKEY_CMPR_LEN]; |
| 309 | |
| 310 | assert(in < psbt->num_inputs); |
| 311 | |
| 312 | /* Find the key identifier fingerprint: |
| 313 | * the first 32 bits of the identifier, where the identifier |
| 314 | * is the hash160 of the ECDSA serialized public key |
| 315 | * https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers |
| 316 | * */ |
| 317 | pubkey_to_hash160(pubkey, &hash); |
| 318 | memcpy(fingerprint, hash.u.u8, sizeof(fingerprint)); |
| 319 | |
| 320 | /* we serialize the compressed version of the key, wally likes this */ |
| 321 | pubkey_to_der(pk_der, pubkey); |
| 322 | |
| 323 | tal_wally_start(); |
| 324 | if (is_taproot) { |
| 325 | wally_err = wally_psbt_input_taproot_keypath_add(&psbt->inputs[in], |
| 326 | pk_der + 1, 32, |
| 327 | NULL /* tapleaf_hashes */, 0 /* tapleaf_hashes_len */, |
| 328 | fingerprint, sizeof(fingerprint), |
| 329 | empty_path, ARRAY_SIZE(empty_path)); |
| 330 | assert(wally_err == WALLY_OK); |
| 331 | } else { |
| 332 | wally_err = wally_psbt_input_keypath_add(&psbt->inputs[in], |
| 333 | pk_der, sizeof(pk_der), |
| 334 | fingerprint, sizeof(fingerprint), |
| 335 | empty_path, ARRAY_SIZE(empty_path)); |
| 336 | assert(wally_err == WALLY_OK); |
| 337 | } |
| 338 | tal_wally_end(psbt); |
| 339 | } |
| 340 | |
| 341 | bool psbt_input_set_signature(struct wally_psbt *psbt, size_t in, |
| 342 | const struct pubkey *pubkey, |
no test coverage detected