| 233 | } |
| 234 | |
| 235 | void psbt_input_add_pubkey(struct wally_psbt *psbt, size_t in, |
| 236 | const struct pubkey *pubkey) |
| 237 | { |
| 238 | int wally_err; |
| 239 | u32 empty_path[1] = {0}; |
| 240 | unsigned char fingerprint[4]; |
| 241 | struct ripemd160 hash; |
| 242 | u8 pk_der[PUBKEY_CMPR_LEN]; |
| 243 | |
| 244 | assert(in < psbt->num_inputs); |
| 245 | |
| 246 | /* Find the key identifier fingerprint: |
| 247 | * the first 32 bits of the identifier, where the identifier |
| 248 | * is the hash160 of the ECDSA serialized public key |
| 249 | * https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers |
| 250 | * */ |
| 251 | pubkey_to_hash160(pubkey, &hash); |
| 252 | memcpy(fingerprint, hash.u.u8, sizeof(fingerprint)); |
| 253 | |
| 254 | /* we serialize the compressed version of the key, wally likes this */ |
| 255 | pubkey_to_der(pk_der, pubkey); |
| 256 | |
| 257 | tal_wally_start(); |
| 258 | wally_err = wally_psbt_input_add_keypath_item(&psbt->inputs[in], |
| 259 | pk_der, sizeof(pk_der), |
| 260 | fingerprint, sizeof(fingerprint), |
| 261 | empty_path, ARRAY_SIZE(empty_path)); |
| 262 | assert(wally_err == WALLY_OK); |
| 263 | tal_wally_end(psbt); |
| 264 | } |
| 265 | |
| 266 | bool psbt_input_set_signature(struct wally_psbt *psbt, size_t in, |
| 267 | const struct pubkey *pubkey, |
no test coverage detected