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

Function psbt_input_add_pubkey

bitcoin/psbt.c:235–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void 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
266bool psbt_input_set_signature(struct wally_psbt *psbt, size_t in,
267 const struct pubkey *pubkey,

Callers 5

sign_our_inputsFunction · 0.85
migrate_last_tx_to_psbtFunction · 0.85
channel_txsFunction · 0.85
initial_channel_txFunction · 0.85

Calls 4

tal_wally_startFunction · 0.85
tal_wally_endFunction · 0.85
pubkey_to_hash160Function · 0.70
pubkey_to_derFunction · 0.70

Tested by

no test coverage detected