Called after lightningd has signed the inputs. */
| 142 | |
| 143 | /* Called after lightningd has signed the inputs. */ |
| 144 | static 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 | |
| 177 | static struct command_result *finish_txprepare(struct command *cmd, |
| 178 | struct txprepare *txp) |
nothing calls this directly
no test coverage detected