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

Function signpsbt_done

plugins/txprepare.c:144–175  ·  view source on GitHub ↗

Called after lightningd has signed the inputs. */

Source from the content-addressed store, hash-verified

142
143/* Called after lightningd has signed the inputs. */
144static struct command_result *signpsbt_done(struct command *cmd,
145 const char *buf,
146 const jsmntok_t *result,
147 struct unreleased_tx *utx)
148{
149 struct out_req *req;
150 const jsmntok_t *psbttok = json_get_member(buf, result, "signed_psbt");
151 struct bitcoin_txid txid;
152
153 tal_free(utx->psbt);
154 utx->psbt = json_tok_psbt(utx, buf, psbttok);
155 /* Replace with signed tx. */
156 tal_free(utx->tx);
157
158 /* The txid from the final should match our expectation. */
159 psbt_txid(utx, utx->psbt, &txid, &utx->tx);
160 if (!bitcoin_txid_eq(&txid, &utx->txid)) {
161 return command_fail(cmd, LIGHTNINGD,
162 "Signed tx changed txid? Had '%s' now '%s'",
163 tal_hex(tmpctx,
164 linearize_wtx(tmpctx, utx->tx)),
165 tal_hex(tmpctx,
166 linearize_wtx(tmpctx,
167 utx->psbt->tx)));
168 }
169
170 req = jsonrpc_request_start(cmd->plugin, cmd, "sendpsbt",
171 sendpsbt_done, forward_error,
172 utx);
173 json_add_psbt(req->js, "psbt", utx->psbt);
174 return send_outreq(cmd->plugin, req);
175}
176
177static struct command_result *finish_txprepare(struct command *cmd,
178 struct txprepare *txp)

Callers

nothing calls this directly

Calls 9

tal_freeFunction · 0.85
json_tok_psbtFunction · 0.85
psbt_txidFunction · 0.85
tal_hexFunction · 0.85
linearize_wtxFunction · 0.85
json_add_psbtFunction · 0.85
command_failFunction · 0.70
send_outreqFunction · 0.70
json_get_memberFunction · 0.50

Tested by

no test coverage detected