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

Function sendpsbt_done

wallet/walletrpc.c:857–897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

855
856
857static void sendpsbt_done(struct bitcoind *bitcoind UNUSED,
858 bool success, const char *msg,
859 struct sending_psbt *sending)
860{
861 struct lightningd *ld = sending->cmd->ld;
862 struct json_stream *response;
863 struct bitcoin_txid txid;
864 struct amount_sat change;
865
866 if (!success) {
867 /* Unreserve the inputs again. */
868 for (size_t i = 0; i < tal_count(sending->utxos); i++) {
869 wallet_unreserve_utxo(ld->wallet,
870 sending->utxos[i],
871 get_block_height(ld->topology),
872 sending->reserve_blocks);
873 }
874
875 was_pending(command_fail(sending->cmd, LIGHTNINGD,
876 "Error broadcasting transaction: %s."
877 " Unsent tx discarded %s",
878 msg,
879 type_to_string(tmpctx, struct wally_tx,
880 sending->wtx)));
881 return;
882 }
883
884 wallet_transaction_add(ld->wallet, sending->wtx, 0, 0);
885
886 /* Extract the change output and add it to the DB */
887 wallet_extract_owned_outputs(ld->wallet, sending->wtx, NULL, &change);
888 wally_txid(sending->wtx, &txid);
889
890 for (size_t i = 0; i < sending->psbt->num_outputs; i++)
891 maybe_notify_new_external_send(ld, &txid, i, sending->psbt);
892
893 response = json_stream_success(sending->cmd);
894 json_add_hex_talarr(response, "tx", linearize_wtx(tmpctx, sending->wtx));
895 json_add_txid(response, "txid", &txid);
896 was_pending(command_success(sending->cmd, response));
897}
898
899static struct command_result *json_sendpsbt(struct command *cmd,
900 const char *buffer,

Callers

nothing calls this directly

Calls 14

wallet_unreserve_utxoFunction · 0.85
was_pendingFunction · 0.85
wally_txidFunction · 0.85
linearize_wtxFunction · 0.85
wallet_transaction_addFunction · 0.70
get_block_heightFunction · 0.50
command_failFunction · 0.50
type_to_stringClass · 0.50
json_stream_successFunction · 0.50
json_add_hex_talarrFunction · 0.50

Tested by

no test coverage detected