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

Function scriptpubkey_p2tr

bitcoin/script.c:346–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346u8 *scriptpubkey_p2tr(const tal_t *ctx, const struct pubkey *inner_pubkey)
347{
348 unsigned char key_bytes[33];
349 unsigned char tweaked_key_bytes[33];
350 size_t out_len = sizeof(key_bytes);
351 u8 *script = tal_arr(ctx, u8, 0);
352
353 add_op(&script, OP_1);
354
355 secp256k1_ec_pubkey_serialize(secp256k1_ctx, key_bytes, &out_len, &inner_pubkey->pubkey, SECP256K1_EC_COMPRESSED);
356 /* Only commit to inner pubkey in tweak */
357 if (wally_ec_public_key_bip341_tweak(key_bytes, 33, /* merkle_root*/ NULL, 0, 0 /* flags */, tweaked_key_bytes, sizeof(tweaked_key_bytes)) != WALLY_OK)
358 abort();
359
360 /* Cut off the first byte from the serialized compressed key */
361 script_push_bytes(&script, tweaked_key_bytes + 1, sizeof(tweaked_key_bytes) - 1);
362 assert(tal_count(script) == BITCOIN_SCRIPTPUBKEY_P2TR_LEN);
363 return script;
364}
365
366u8 *scriptpubkey_p2tr_derkey(const tal_t *ctx, const u8 inner_der[33])
367{

Callers 8

scriptpubkey_p2tr_derkeyFunction · 0.85
encode_pubkey_to_addrFunction · 0.85
p2tr_for_keyidxFunction · 0.85
onchaind_tx_unsignedFunction · 0.85
anchor_psbtFunction · 0.85
json_invoiceFunction · 0.85

Calls 3

add_opFunction · 0.85
abortFunction · 0.85
script_push_bytesFunction · 0.85

Tested by

no test coverage detected