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

Function log_chain_event

plugins/bkpr/recorder.c:1979–2050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1977}
1978
1979bool log_chain_event(struct db *db,
1980 const struct account *acct,
1981 struct chain_event *e)
1982{
1983 struct db_stmt *stmt;
1984
1985 /* We're responsible for de-duping chain events! */
1986 if (find_chain_event(e, db, acct,
1987 &e->outpoint, e->spending_txid,
1988 e->tag))
1989 return false;
1990
1991 stmt = db_prepare_v2(db, SQL("INSERT INTO chain_events"
1992 " ("
1993 " account_id"
1994 ", origin"
1995 ", tag"
1996 ", credit"
1997 ", debit"
1998 ", output_value"
1999 ", currency"
2000 ", timestamp"
2001 ", blockheight"
2002 ", utxo_txid"
2003 ", outnum"
2004 ", payment_id"
2005 ", spending_txid"
2006 ", ignored"
2007 ", stealable"
2008 ", ev_desc"
2009 ")"
2010 " VALUES "
2011 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
2012
2013 db_bind_u64(stmt, 0, acct->db_id);
2014 if (e->origin_acct)
2015 db_bind_text(stmt, 1, e->origin_acct);
2016 else
2017 db_bind_null(stmt, 1);
2018 db_bind_text(stmt, 2, e->tag);
2019 db_bind_amount_msat(stmt, 3, &e->credit);
2020 db_bind_amount_msat(stmt, 4, &e->debit);
2021 db_bind_amount_msat(stmt, 5, &e->output_value);
2022 db_bind_text(stmt, 6, e->currency);
2023 db_bind_u64(stmt, 7, e->timestamp);
2024 db_bind_int(stmt, 8, e->blockheight);
2025 db_bind_txid(stmt, 9, &e->outpoint.txid);
2026 db_bind_int(stmt, 10, e->outpoint.n);
2027
2028 if (e->payment_id)
2029 db_bind_sha256(stmt, 11, e->payment_id);
2030 else
2031 db_bind_null(stmt, 11);
2032
2033 if (e->spending_txid)
2034 db_bind_txid(stmt, 12, e->spending_txid);
2035 else
2036 db_bind_null(stmt, 12);

Callers 8

parse_and_log_chain_moveFunction · 0.85
test_chain_event_crudFunction · 0.85
test_account_balancesFunction · 0.85
test_account_crudFunction · 0.85

Calls 11

find_chain_eventFunction · 0.85
db_bind_u64Function · 0.85
db_bind_textFunction · 0.85
db_bind_nullFunction · 0.85
db_bind_amount_msatFunction · 0.85
db_bind_intFunction · 0.85
db_bind_txidFunction · 0.85
db_bind_sha256Function · 0.85
db_exec_prepared_v2Function · 0.85
db_last_insert_id_v2Function · 0.85
tal_freeFunction · 0.85

Tested by 6

test_chain_event_crudFunction · 0.68
test_account_balancesFunction · 0.68
test_account_crudFunction · 0.68