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

Function psbt_has_required_fields

common/psbt_open.c:442–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440}
441
442bool psbt_has_required_fields(struct wally_psbt *psbt)
443{
444 u64 serial_id;
445 for (size_t i = 0; i < psbt->num_inputs; i++) {
446 const struct wally_map_item *redeem_script;
447 const struct wally_tx_output *txout;
448 struct wally_psbt_input *input = &psbt->inputs[i];
449
450 if (!psbt_get_serial_id(&input->unknowns, &serial_id))
451 return false;
452
453 /* Required because we send the full tx over the wire now */
454 if (!input->utxo)
455 return false;
456
457 assert(input->index < input->utxo->num_outputs);
458 txout = &input->utxo->outputs[input->index];
459 if (!is_p2sh(txout->script, txout->script_len, NULL))
460 continue;
461 /* P2SH: redeemscript must be present */
462 const u32 key = 0x04; /* PSBT_IN_REDEEM_SCRIPT */
463 redeem_script = wally_map_get_integer(&input->psbt_fields, key);
464 if (!redeem_script || !redeem_script->value_len)
465 return false;
466 }
467
468 for (size_t i = 0; i < psbt->num_outputs; i++) {
469 if (!psbt_get_serial_id(&psbt->outputs[i].unknowns, &serial_id))
470 return false;
471 }
472
473 return true;
474}
475
476bool psbt_side_finalized(const struct wally_psbt *psbt, enum tx_role role)
477{

Calls 2

psbt_get_serial_idFunction · 0.85
is_p2shFunction · 0.50

Tested by

no test coverage detected