| 3103 | }; |
| 3104 | |
| 3105 | static void validate_input_unspent(struct bitcoind *bitcoind, |
| 3106 | const struct bitcoin_tx_output *txout, |
| 3107 | void *arg) |
| 3108 | { |
| 3109 | struct psbt_validator *pv = arg; |
| 3110 | char *err; |
| 3111 | |
| 3112 | /* First time thru bitcoind will be NULL, otherwise is response */ |
| 3113 | if (bitcoind && !txout) { |
| 3114 | struct bitcoin_outpoint outpoint; |
| 3115 | |
| 3116 | assert(pv->next_index > 0); |
| 3117 | wally_psbt_input_get_outpoint(&pv->psbt->inputs[pv->next_index - 1], |
| 3118 | &outpoint); |
| 3119 | |
| 3120 | err = tal_fmt(pv, "Requested only confirmed" |
| 3121 | " inputs for this open." |
| 3122 | " Input %s is not confirmed.", |
| 3123 | fmt_bitcoin_outpoint(tmpctx, &outpoint)); |
| 3124 | pv->invalid_input(pv, err); |
| 3125 | return; |
| 3126 | } |
| 3127 | |
| 3128 | for (size_t i = pv->next_index; i < pv->psbt->num_inputs; i++) { |
| 3129 | struct bitcoin_outpoint outpoint; |
| 3130 | u64 serial; |
| 3131 | |
| 3132 | if (!psbt_get_serial_id(&pv->psbt->inputs[i].unknowns, &serial)) { |
| 3133 | err = tal_fmt(pv, "PSBT input at index %zu" |
| 3134 | " missing serial id", i); |
| 3135 | pv->invalid_input(pv, err); |
| 3136 | return; |
| 3137 | } |
| 3138 | /* Ignore any input that's not what we're looking for */ |
| 3139 | if (serial % 2 != pv->role_to_validate) |
| 3140 | continue; |
| 3141 | |
| 3142 | wally_psbt_input_get_outpoint(&pv->psbt->inputs[i], |
| 3143 | &outpoint); |
| 3144 | pv->next_index = i + 1; |
| 3145 | |
| 3146 | /* Confirm input is in a block */ |
| 3147 | bitcoind_getutxout(pv, pv->channel->owner->ld->topology->bitcoind, |
| 3148 | &outpoint, |
| 3149 | validate_input_unspent, |
| 3150 | pv); |
| 3151 | return; |
| 3152 | } |
| 3153 | |
| 3154 | pv->success(pv); |
| 3155 | } |
| 3156 | |
| 3157 | static void openchannel_update_valid_psbt(struct psbt_validator *pv) |
| 3158 | { |
no test coverage detected