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

Function validate_input_unspent

lightningd/dual_open_control.c:2819–2869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2817};
2818
2819static void validate_input_unspent(struct bitcoind *bitcoind,
2820 const struct bitcoin_tx_output *txout,
2821 void *arg)
2822{
2823 struct psbt_validator *pv = arg;
2824 char *err;
2825
2826 /* First time thru bitcoind will be NULL, otherwise is response */
2827 if (bitcoind && !txout) {
2828 struct bitcoin_outpoint outpoint;
2829
2830 assert(pv->next_index > 0);
2831 wally_psbt_input_get_outpoint(&pv->psbt->inputs[pv->next_index - 1],
2832 &outpoint);
2833
2834 err = tal_fmt(pv, "Requested only confirmed"
2835 " inputs for this open."
2836 " Input %s is not confirmed.",
2837 fmt_bitcoin_outpoint(tmpctx, &outpoint));
2838 pv->invalid_input(pv, err);
2839 return;
2840 }
2841
2842 for (size_t i = pv->next_index; i < pv->psbt->num_inputs; i++) {
2843 struct bitcoin_outpoint outpoint;
2844 u64 serial;
2845
2846 if (!psbt_get_serial_id(&pv->psbt->inputs[i].unknowns, &serial)) {
2847 err = tal_fmt(pv, "PSBT input at index %zu"
2848 " missing serial id", i);
2849 pv->invalid_input(pv, err);
2850 return;
2851 }
2852 /* Ignore any input that's not what we're looking for */
2853 if (serial % 2 != pv->role_to_validate)
2854 continue;
2855
2856 wally_psbt_input_get_outpoint(&pv->psbt->inputs[i],
2857 &outpoint);
2858 pv->next_index = i + 1;
2859
2860 /* Confirm input is in a block */
2861 bitcoind_getutxout(pv, pv->channel->owner->ld->topology->bitcoind,
2862 &outpoint,
2863 validate_input_unspent,
2864 pv);
2865 return;
2866 }
2867
2868 pv->success(pv);
2869}
2870
2871static void openchannel_update_valid_psbt(struct psbt_validator *pv)
2872{

Callers 2

json_openchannel_updateFunction · 0.85
handle_validate_inputsFunction · 0.85

Calls 4

fmt_bitcoin_outpointFunction · 0.85
psbt_get_serial_idFunction · 0.85
successMethod · 0.80

Tested by

no test coverage detected