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

Function send_next

common/interactivetx.c:207–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205 e[24], e[25], e[25], e[26], e[28], e[29], e[30], e[31]
206
207static char *send_next(const tal_t *ctx,
208 struct interactivetx_context *ictx,
209 bool *finished)
210{
211 struct channel_id *cid = &ictx->channel_id;
212 struct psbt_changeset *set = ictx->change_set;
213 u64 serial_id;
214 u8 *msg;
215 *finished = false;
216
217 if (!set)
218 goto tx_complete;
219
220 if (tal_count(set->added_ins) != 0) {
221 const struct input_set *in = &set->added_ins[0];
222 struct bitcoin_outpoint point;
223 u8 *prevtx;
224
225 if (!psbt_get_serial_id(&in->input.unknowns, &serial_id))
226 return "interactivetx ADD_INPUT PSBT has invalid"
227 " serial_id.";
228
229 if (in->input.utxo)
230 prevtx = linearize_wtx(ctx, in->input.utxo);
231 else
232 return "interactivetx ADD_INPUT PSBT needs the previous"
233 " transaction set.";
234
235 wally_psbt_input_get_outpoint(&in->input, &point);
236
237 /* If this is the shared channel input, we send funding txid in
238 * tlvs and do not send prevtx */
239 if (ictx->shared_outpoint) {
240 status_debug("ictx->shared_outpoint=%s",
241 fmt_bitcoin_outpoint(tmpctx,
242 ictx->shared_outpoint));
243 }
244 else {
245 status_debug("ictx->shared_outpoint = NULL");
246 }
247 status_debug("point=%s", fmt_bitcoin_outpoint(tmpctx, &point));
248
249 if (ictx->shared_outpoint
250 && bitcoin_outpoint_eq(&point, ictx->shared_outpoint)) {
251 struct tlv_tx_add_input_tlvs *tlvs = tlv_tx_add_input_tlvs_new(tmpctx);
252 tlvs->shared_input_txid = tal_dup(tlvs,
253 struct bitcoin_txid,
254 &point.txid);
255 status_debug("Adding shared input %s",
256 tal_hexstr(ctx, &serial_id,
257 sizeof(serial_id)));
258 msg = towire_tx_add_input(NULL, cid, serial_id,
259 NULL, in->input.index,
260 in->input.sequence, tlvs);
261 } else {
262 msg = towire_tx_add_input(NULL, cid, serial_id,
263 prevtx, in->input.index,
264 in->input.sequence, NULL);

Callers 1

Calls 9

psbt_get_serial_idFunction · 0.85
linearize_wtxFunction · 0.85
fmt_bitcoin_outpointFunction · 0.85
tal_hexstrFunction · 0.85
peer_writeFunction · 0.85
amount_asset_to_satFunction · 0.70

Tested by

no test coverage detected