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

Function json_utxo_spend

plugins/bkpr/bookkeeper.c:1745–1789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1743}
1744
1745static struct command_result *json_utxo_spend(struct command *cmd, const char *buf, const jsmntok_t *params)
1746{
1747 const char *acct_name;
1748 struct amount_msat amount;
1749 struct bitcoin_txid spending_txid;
1750 struct bitcoin_outpoint outpoint;
1751 u64 timestamp;
1752 u32 blockheight;
1753 const char *err;
1754 struct out_req *req;
1755
1756 err = json_scan(tmpctx, buf, params,
1757 "{utxo_spend:{"
1758 "account:%"
1759 ",outpoint:%"
1760 ",spending_txid:%"
1761 ",amount_msat:%"
1762 ",timestamp:%"
1763 ",blockheight:%"
1764 "}}",
1765 JSON_SCAN_TAL(tmpctx, json_strdup, &acct_name),
1766 JSON_SCAN(json_to_outpoint, &outpoint),
1767 JSON_SCAN(json_to_txid, &spending_txid),
1768 JSON_SCAN(json_to_msat, &amount),
1769 JSON_SCAN(json_to_u64, &timestamp),
1770 JSON_SCAN(json_to_u32, &blockheight));
1771
1772 if (err)
1773 plugin_err(cmd->plugin,
1774 "`utxo_spend` parameters did not scan %s: %.*s",
1775 err, json_tok_full_len(params),
1776 json_tok_full(buf, params));
1777
1778 req = jsonrpc_request_start(cmd, "injectutxospend",
1779 inject_done,
1780 plugin_broken_cb,
1781 NULL);
1782 json_add_string(req->js, "account", acct_name);
1783 json_add_outpoint(req->js, "outpoint", &outpoint);
1784 json_add_txid(req->js, "spending_txid", &spending_txid);
1785 json_add_amount_msat(req->js, "amount_msat", amount);
1786 json_add_u64(req->js, "timestamp", timestamp);
1787 json_add_u32(req->js, "blockheight", blockheight);
1788 return send_outreq(req);
1789}
1790
1791const struct plugin_notification notifs[] = {
1792 {

Callers

nothing calls this directly

Calls 11

json_add_outpointFunction · 0.85
json_add_txidFunction · 0.85
json_add_amount_msatFunction · 0.85
json_add_u64Function · 0.85
json_add_u32Function · 0.85
json_scanFunction · 0.50
plugin_errFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_add_stringFunction · 0.50
send_outreqFunction · 0.50

Tested by

no test coverage detected