mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
db: adds a state_change history to database
This commit is contained in:
parent
68ce25c92d
commit
88c1dc56e8
@ -456,9 +456,16 @@ void channel_set_state(struct channel *channel,
|
||||
/* TODO(cdecker) Selectively save updated fields to DB */
|
||||
wallet_channel_save(channel->peer->ld->wallet, channel);
|
||||
|
||||
/* plugin notification channel_state_changed */
|
||||
/* plugin notification channel_state_changed and DB entry */
|
||||
if (state != old_state) { /* see issue #4029 */
|
||||
timestamp = time_now();
|
||||
wallet_state_change_add(channel->peer->ld->wallet,
|
||||
channel->dbid,
|
||||
×tamp,
|
||||
old_state,
|
||||
state,
|
||||
reason,
|
||||
why);
|
||||
derive_channel_id(&cid, &channel->funding_txid, channel->funding_outnum);
|
||||
notify_channel_state_changed(channel->peer->ld,
|
||||
&channel->peer->id,
|
||||
|
@ -90,6 +90,7 @@ static void warning_notification_serialize(struct json_stream *stream,
|
||||
/* unsuaul/broken event is rare, plugin pay more attentions on
|
||||
* the absolute time, like when channels failed. */
|
||||
json_add_time(stream, "time", l->time.ts);
|
||||
json_add_timeiso(stream, "timestamp", &l->time);
|
||||
json_add_string(stream, "source", l->prefix);
|
||||
json_add_string(stream, "log", l->log);
|
||||
json_object_end(stream); /* .warning */
|
||||
|
@ -649,6 +649,14 @@ static struct migration dbmigrations[] = {
|
||||
/* Channel closure reason */
|
||||
{SQL("ALTER TABLE channels ADD closer INTEGER DEFAULT 2;"), NULL},
|
||||
{SQL("ALTER TABLE channels ADD state_change_reason INTEGER DEFAULT 0;"), NULL},
|
||||
{SQL("CREATE TABLE channel_state_changes ("
|
||||
" channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE,"
|
||||
" timestamp BIGINT,"
|
||||
" old_state INTEGER,"
|
||||
" new_state INTEGER,"
|
||||
" cause INTEGER,"
|
||||
" message TEXT"
|
||||
");"), NULL},
|
||||
};
|
||||
|
||||
/* Leak tracking. */
|
||||
|
16
wallet/db_postgres_sqlgen.c
generated
16
wallet/db_postgres_sqlgen.c
generated
@ -842,6 +842,12 @@ struct db_query db_postgres_queries[] = {
|
||||
.placeholders = 0,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
|
||||
.query = "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
|
||||
.placeholders = 0,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
||||
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = $1",
|
||||
@ -1244,6 +1250,12 @@ struct db_query db_postgres_queries[] = {
|
||||
.placeholders = 2,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
.query = "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES ($1, $2, $3, $4, $5, $6);",
|
||||
.placeholders = 6,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "SELECT id FROM peers WHERE node_id = ?",
|
||||
.query = "SELECT id FROM peers WHERE node_id = $1",
|
||||
@ -1666,10 +1678,10 @@ struct db_query db_postgres_queries[] = {
|
||||
},
|
||||
};
|
||||
|
||||
#define DB_POSTGRES_QUERY_COUNT 276
|
||||
#define DB_POSTGRES_QUERY_COUNT 278
|
||||
|
||||
#endif /* HAVE_POSTGRES */
|
||||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
|
||||
|
||||
// SHA256STAMP:5f01b4eb0c1df3e18b6d3f7af23a509d584b12b8b0a637451576d2ef80bed04f
|
||||
// SHA256STAMP:9ed50e3cbb14e9bb979a6b0f8754f1cb2412a7adc032f0a71e88cd534b3828d4
|
||||
|
16
wallet/db_sqlite3_sqlgen.c
generated
16
wallet/db_sqlite3_sqlgen.c
generated
@ -842,6 +842,12 @@ struct db_query db_sqlite3_queries[] = {
|
||||
.placeholders = 0,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
|
||||
.query = "CREATE TABLE channel_state_changes ( channel_id INTEGER REFERENCES channels(id) ON DELETE CASCADE, timestamp INTEGER, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
|
||||
.placeholders = 0,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
||||
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
|
||||
@ -1244,6 +1250,12 @@ struct db_query db_sqlite3_queries[] = {
|
||||
.placeholders = 2,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
.query = "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
.placeholders = 6,
|
||||
.readonly = false,
|
||||
},
|
||||
{
|
||||
.name = "SELECT id FROM peers WHERE node_id = ?",
|
||||
.query = "SELECT id FROM peers WHERE node_id = ?",
|
||||
@ -1666,10 +1678,10 @@ struct db_query db_sqlite3_queries[] = {
|
||||
},
|
||||
};
|
||||
|
||||
#define DB_SQLITE3_QUERY_COUNT 276
|
||||
#define DB_SQLITE3_QUERY_COUNT 278
|
||||
|
||||
#endif /* HAVE_SQLITE3 */
|
||||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
|
||||
|
||||
// SHA256STAMP:5f01b4eb0c1df3e18b6d3f7af23a509d584b12b8b0a637451576d2ef80bed04f
|
||||
// SHA256STAMP:9ed50e3cbb14e9bb979a6b0f8754f1cb2412a7adc032f0a71e88cd534b3828d4
|
||||
|
176
wallet/statements_gettextgen.po
generated
176
wallet/statements_gettextgen.po
generated
@ -554,67 +554,71 @@ msgstr ""
|
||||
msgid "ALTER TABLE channels ADD state_change_reason INTEGER DEFAULT 0;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:878
|
||||
#: wallet/db.c:652
|
||||
msgid "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:886
|
||||
msgid "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:978
|
||||
#: wallet/db.c:986
|
||||
msgid "SELECT version FROM version LIMIT 1"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1036
|
||||
#: wallet/db.c:1044
|
||||
msgid "UPDATE version SET version=?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1044
|
||||
#: wallet/db.c:1052
|
||||
msgid "INSERT INTO db_upgrades VALUES (?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1056
|
||||
#: wallet/db.c:1064
|
||||
msgid "SELECT intval FROM vars WHERE name = 'data_version'"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1083
|
||||
#: wallet/db.c:1091
|
||||
msgid "SELECT intval FROM vars WHERE name= ? LIMIT 1"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1099
|
||||
#: wallet/db.c:1107
|
||||
msgid "UPDATE vars SET intval=? WHERE name=?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1108
|
||||
#: wallet/db.c:1116
|
||||
msgid "INSERT INTO vars (name, intval) VALUES (?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1122
|
||||
#: wallet/db.c:1130
|
||||
msgid "UPDATE channels SET feerate_base = ?, feerate_ppm = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1143
|
||||
#: wallet/db.c:1151
|
||||
msgid "UPDATE channels SET our_funding_satoshi = funding_satoshi WHERE funder = 0;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1159
|
||||
#: wallet/db.c:1167
|
||||
msgid "SELECT type, keyindex, prev_out_tx, prev_out_index, channel_id, peer_id, commitment_point FROM outputs WHERE scriptpubkey IS NULL;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1221
|
||||
#: wallet/db.c:1229
|
||||
msgid "UPDATE outputs SET scriptpubkey = ? WHERE prev_out_tx = ? AND prev_out_index = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1246
|
||||
#: wallet/db.c:1254
|
||||
msgid "SELECT id, funding_tx_id, funding_tx_outnum FROM channels;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1265
|
||||
#: wallet/db.c:1273
|
||||
msgid "UPDATE channels SET full_channel_id = ? WHERE id = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1288
|
||||
#: wallet/db.c:1296
|
||||
msgid "SELECT c.id, p.node_id, c.last_tx, c.funding_satoshi, c.fundingkey_remote, c.last_sig FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/db.c:1355
|
||||
#: wallet/db.c:1363
|
||||
msgid "UPDATE channels SET last_tx = ? WHERE id = ?;"
|
||||
msgstr ""
|
||||
|
||||
@ -822,271 +826,275 @@ msgstr ""
|
||||
msgid "UPDATE channels SET last_sent_commit=? WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1581
|
||||
#: wallet/wallet.c:1586
|
||||
msgid "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES (?, ?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1610
|
||||
msgid "SELECT id FROM peers WHERE node_id = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1593
|
||||
#: wallet/wallet.c:1622
|
||||
msgid "UPDATE peers SET address = ? WHERE id = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1602
|
||||
#: wallet/wallet.c:1631
|
||||
msgid "INSERT INTO peers (node_id, address) VALUES (?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1620
|
||||
#: wallet/wallet.c:1649
|
||||
msgid "INSERT INTO channels (peer_id, first_blocknum, id) VALUES (?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1646
|
||||
#: wallet/wallet.c:1675
|
||||
msgid "DELETE FROM channel_htlcs WHERE channel_id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1652
|
||||
#: wallet/wallet.c:1681
|
||||
msgid "DELETE FROM htlc_sigs WHERE channelid=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1658
|
||||
#: wallet/wallet.c:1687
|
||||
msgid "DELETE FROM channeltxs WHERE channel_id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1664
|
||||
#: wallet/wallet.c:1693
|
||||
msgid "DELETE FROM shachains WHERE id IN ( SELECT shachain_remote_id FROM channels WHERE channels.id=?)"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1674
|
||||
#: wallet/wallet.c:1703
|
||||
msgid "UPDATE channels SET state=?, peer_id=? WHERE channels.id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1688
|
||||
#: wallet/wallet.c:1717
|
||||
msgid "SELECT * FROM channels WHERE peer_id = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1696
|
||||
#: wallet/wallet.c:1725
|
||||
msgid "DELETE FROM peers WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1707
|
||||
#: wallet/wallet.c:1736
|
||||
msgid "UPDATE outputs SET confirmation_height = ? WHERE prev_out_tx = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1810
|
||||
#: wallet/wallet.c:1839
|
||||
msgid "INSERT INTO channel_htlcs ( channel_id, channel_htlc_id, direction, msatoshi, cltv_expiry, payment_hash, payment_key, hstate, shared_secret, routing_onion, received_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1863
|
||||
#: wallet/wallet.c:1892
|
||||
msgid "INSERT INTO channel_htlcs ( channel_id, channel_htlc_id, direction, origin_htlc, msatoshi, cltv_expiry, payment_hash, payment_key, hstate, routing_onion, partid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:1923
|
||||
#: wallet/wallet.c:1952
|
||||
msgid "UPDATE channel_htlcs SET hstate=?, payment_key=?, malformed_onion=?, failuremsg=?, localfailmsg=?, we_filled=? WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2139
|
||||
#: wallet/wallet.c:2168
|
||||
msgid "SELECT id, channel_htlc_id, msatoshi, cltv_expiry, hstate, payment_hash, payment_key, routing_onion, failuremsg, malformed_onion, origin_htlc, shared_secret, received_time, we_filled FROM channel_htlcs WHERE direction= ? AND channel_id= ? AND hstate != ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2186
|
||||
#: wallet/wallet.c:2215
|
||||
msgid "SELECT id, channel_htlc_id, msatoshi, cltv_expiry, hstate, payment_hash, payment_key, routing_onion, failuremsg, malformed_onion, origin_htlc, shared_secret, received_time, partid, localfailmsg FROM channel_htlcs WHERE direction = ? AND channel_id = ? AND hstate != ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2316
|
||||
#: wallet/wallet.c:2345
|
||||
msgid "SELECT channel_id, direction, cltv_expiry, channel_htlc_id, payment_hash FROM channel_htlcs WHERE channel_id = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2350
|
||||
#: wallet/wallet.c:2379
|
||||
msgid "DELETE FROM channel_htlcs WHERE direction = ? AND origin_htlc = ? AND payment_hash = ? AND partid = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2403
|
||||
#: wallet/wallet.c:2432
|
||||
msgid "SELECT status FROM payments WHERE payment_hash=? AND partid = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2421
|
||||
#: wallet/wallet.c:2450
|
||||
msgid "INSERT INTO payments ( status, payment_hash, destination, msatoshi, timestamp, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, total_msat, partid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2504
|
||||
#: wallet/wallet.c:2533
|
||||
msgid "DELETE FROM payments WHERE payment_hash = ? AND partid = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2518
|
||||
#: wallet/wallet.c:2547
|
||||
msgid "DELETE FROM payments WHERE payment_hash = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2613
|
||||
#: wallet/wallet.c:2642
|
||||
msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid FROM payments WHERE payment_hash = ? AND partid = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2662
|
||||
#: wallet/wallet.c:2691
|
||||
msgid "UPDATE payments SET status=? WHERE payment_hash=? AND partid=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2672
|
||||
#: wallet/wallet.c:2701
|
||||
msgid "UPDATE payments SET payment_preimage=? WHERE payment_hash=? AND partid=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2682
|
||||
#: wallet/wallet.c:2711
|
||||
msgid "UPDATE payments SET path_secrets = NULL , route_nodes = NULL , route_channels = NULL WHERE payment_hash = ? AND partid = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2714
|
||||
#: wallet/wallet.c:2743
|
||||
msgid "SELECT failonionreply, faildestperm, failindex, failcode, failnode, failchannel, failupdate, faildetail, faildirection FROM payments WHERE payment_hash=? AND partid=?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2781
|
||||
#: wallet/wallet.c:2810
|
||||
msgid "UPDATE payments SET failonionreply=? , faildestperm=? , failindex=? , failcode=? , failnode=? , failchannel=? , failupdate=? , faildetail=? , faildirection=? WHERE payment_hash=? AND partid=?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2840
|
||||
#: wallet/wallet.c:2869
|
||||
msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid FROM payments WHERE payment_hash = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2861
|
||||
#: wallet/wallet.c:2890
|
||||
msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid FROM payments ORDER BY id;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2905
|
||||
#: wallet/wallet.c:2934
|
||||
msgid "DELETE FROM htlc_sigs WHERE channelid = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2912
|
||||
#: wallet/wallet.c:2941
|
||||
msgid "INSERT INTO htlc_sigs (channelid, signature) VALUES (?, ?)"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2924
|
||||
#: wallet/wallet.c:2953
|
||||
msgid "SELECT blobval FROM vars WHERE name='genesis_hash'"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2948
|
||||
#: wallet/wallet.c:2977
|
||||
msgid "INSERT INTO vars (name, blobval) VALUES ('genesis_hash', ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2964
|
||||
#: wallet/wallet.c:2993
|
||||
msgid "DELETE FROM utxoset WHERE spendheight < ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2972 wallet/wallet.c:3082
|
||||
#: wallet/wallet.c:3001 wallet/wallet.c:3111
|
||||
msgid "INSERT INTO blocks (height, hash, prev_hash) VALUES (?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2991
|
||||
#: wallet/wallet.c:3020
|
||||
msgid "DELETE FROM blocks WHERE hash = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:2997
|
||||
#: wallet/wallet.c:3026
|
||||
msgid "SELECT * FROM blocks WHERE height >= ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3006
|
||||
#: wallet/wallet.c:3035
|
||||
msgid "DELETE FROM blocks WHERE height > ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3018
|
||||
#: wallet/wallet.c:3047
|
||||
msgid "UPDATE outputs SET spend_height = ?, status = ? WHERE prev_out_tx = ? AND prev_out_index = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3035
|
||||
#: wallet/wallet.c:3064
|
||||
msgid "UPDATE utxoset SET spendheight = ? WHERE txid = ? AND outnum = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3057 wallet/wallet.c:3093
|
||||
#: wallet/wallet.c:3086 wallet/wallet.c:3122
|
||||
msgid "INSERT INTO utxoset ( txid, outnum, blockheight, spendheight, txindex, scriptpubkey, satoshis) VALUES(?, ?, ?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3117
|
||||
#: wallet/wallet.c:3146
|
||||
msgid "SELECT height FROM blocks WHERE height = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3130
|
||||
#: wallet/wallet.c:3159
|
||||
msgid "SELECT txid, spendheight, scriptpubkey, satoshis FROM utxoset WHERE blockheight = ? AND txindex = ? AND outnum = ? AND spendheight IS NULL"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3172
|
||||
#: wallet/wallet.c:3201
|
||||
msgid "SELECT blockheight, txindex, outnum FROM utxoset WHERE spendheight = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3203 wallet/wallet.c:3363
|
||||
#: wallet/wallet.c:3232 wallet/wallet.c:3392
|
||||
msgid "SELECT blockheight FROM transactions WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3213
|
||||
#: wallet/wallet.c:3242
|
||||
msgid "INSERT INTO transactions ( id, blockheight, txindex, rawtx) VALUES (?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3234
|
||||
#: wallet/wallet.c:3263
|
||||
msgid "UPDATE transactions SET blockheight = ?, txindex = ? WHERE id = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3251
|
||||
#: wallet/wallet.c:3280
|
||||
msgid "INSERT INTO transaction_annotations (txid, idx, location, type, channel) VALUES (?, ?, ?, ?, ?) ON CONFLICT(txid,idx) DO NOTHING;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3283
|
||||
#: wallet/wallet.c:3312
|
||||
msgid "SELECT type, channel_id FROM transactions WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3299
|
||||
#: wallet/wallet.c:3328
|
||||
msgid "UPDATE transactions SET type = ?, channel_id = ? WHERE id = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3318
|
||||
#: wallet/wallet.c:3347
|
||||
msgid "SELECT type FROM transactions WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3341
|
||||
#: wallet/wallet.c:3370
|
||||
msgid "SELECT rawtx FROM transactions WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3387
|
||||
#: wallet/wallet.c:3416
|
||||
msgid "SELECT blockheight, txindex FROM transactions WHERE id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3415
|
||||
#: wallet/wallet.c:3444
|
||||
msgid "SELECT id FROM transactions WHERE blockheight=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3434
|
||||
#: wallet/wallet.c:3463
|
||||
msgid "INSERT INTO channeltxs ( channel_id, type, transaction_id, input_num, blockheight) VALUES (?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3458
|
||||
#: wallet/wallet.c:3487
|
||||
msgid "SELECT DISTINCT(channel_id) FROM channeltxs WHERE type = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3479
|
||||
#: wallet/wallet.c:3508
|
||||
msgid "SELECT c.type, c.blockheight, t.rawtx, c.input_num, c.blockheight - t.blockheight + 1 AS depth, t.id as txid FROM channeltxs c JOIN transactions t ON t.id = c.transaction_id WHERE c.channel_id = ? ORDER BY c.id ASC;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3524
|
||||
#: wallet/wallet.c:3553
|
||||
msgid "UPDATE forwarded_payments SET in_msatoshi=?, out_msatoshi=?, state=?, resolved_time=?, failcode=? WHERE in_htlc_id=?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3582
|
||||
#: wallet/wallet.c:3611
|
||||
msgid "INSERT INTO forwarded_payments ( in_htlc_id, out_htlc_id, in_channel_scid, out_channel_scid, in_msatoshi, out_msatoshi, state, received_time, resolved_time, failcode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3641
|
||||
#: wallet/wallet.c:3670
|
||||
msgid "SELECT CAST(COALESCE(SUM(in_msatoshi - out_msatoshi), 0) AS BIGINT)FROM forwarded_payments WHERE state = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3665
|
||||
#: wallet/wallet.c:3694
|
||||
msgid "SELECT f.state, in_msatoshi, out_msatoshi, hin.payment_hash as payment_hash, in_channel_scid, out_channel_scid, f.received_time, f.resolved_time, f.failcode FROM forwarded_payments f LEFT JOIN channel_htlcs hin ON (f.in_htlc_id = hin.id)"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3753
|
||||
#: wallet/wallet.c:3782
|
||||
msgid "SELECT t.id, t.rawtx, t.blockheight, t.txindex, t.type as txtype, c2.short_channel_id as txchan, a.location, a.idx as ann_idx, a.type as annotation_type, c.short_channel_id FROM transactions t LEFT JOIN transaction_annotations a ON (a.txid = t.id) LEFT JOIN channels c ON (a.channel = c.id) LEFT JOIN channels c2 ON (t.channel_id = c2.id) ORDER BY t.blockheight, t.txindex ASC"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3847
|
||||
#: wallet/wallet.c:3876
|
||||
msgid "INSERT INTO penalty_bases ( channel_id, commitnum, txid, outnum, amount) VALUES (?, ?, ?, ?, ?);"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3872
|
||||
#: wallet/wallet.c:3901
|
||||
msgid "SELECT commitnum, txid, outnum, amount FROM penalty_bases WHERE channel_id = ?"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/wallet.c:3896
|
||||
#: wallet/wallet.c:3925
|
||||
msgid "DELETE FROM penalty_bases WHERE channel_id = ? AND commitnum = ?"
|
||||
msgstr ""
|
||||
|
||||
@ -1101,4 +1109,4 @@ msgstr ""
|
||||
#: wallet/test/run-wallet.c:1371
|
||||
msgid "INSERT INTO channels (id) VALUES (1);"
|
||||
msgstr ""
|
||||
# SHA256STAMP:50d91c4404011657ae39cf1d961cee3c2c313af63ac8ef1cd915bbb7a9973c09
|
||||
# SHA256STAMP:419d2f0d03ce748b3e54bd380834b1fc721c823e38f2ce38fc87df73671743ef
|
||||
|
@ -1573,6 +1573,35 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
||||
tal_free(stmt);
|
||||
}
|
||||
|
||||
void wallet_state_change_add(struct wallet *w,
|
||||
const u64 channel_id,
|
||||
struct timeabs *timestamp,
|
||||
enum channel_state old_state,
|
||||
enum channel_state new_state,
|
||||
enum state_change cause,
|
||||
char *message)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
stmt = db_prepare_v2(w->db,
|
||||
SQL("INSERT INTO channel_state_changes ("
|
||||
" channel_id"
|
||||
", timestamp"
|
||||
", old_state"
|
||||
", new_state"
|
||||
", cause"
|
||||
", message"
|
||||
") VALUES (?, ?, ?, ?, ?, ?);"));
|
||||
|
||||
db_bind_u64(stmt, 0, channel_id);
|
||||
db_bind_timeabs(stmt, 1, *timestamp);
|
||||
db_bind_int(stmt, 2, old_state);
|
||||
db_bind_int(stmt, 3, new_state);
|
||||
db_bind_int(stmt, 4, cause);
|
||||
db_bind_text(stmt, 5, message);
|
||||
|
||||
db_exec_prepared_v2(take(stmt));
|
||||
}
|
||||
|
||||
static void wallet_peer_save(struct wallet *w, struct peer *peer)
|
||||
{
|
||||
const char *addr =
|
||||
|
@ -30,6 +30,8 @@ struct node_id;
|
||||
struct oneshot;
|
||||
struct peer;
|
||||
struct timers;
|
||||
enum channel_state;
|
||||
enum state_change;
|
||||
|
||||
struct wallet {
|
||||
struct lightningd *ld;
|
||||
@ -493,6 +495,17 @@ void wallet_channel_insert(struct wallet *w, struct channel *chan);
|
||||
*/
|
||||
void wallet_channel_close(struct wallet *w, u64 wallet_id);
|
||||
|
||||
/**
|
||||
* Adds a channel state change history entry into the database
|
||||
*/
|
||||
void wallet_state_change_add(struct wallet *w,
|
||||
const u64 channel_id,
|
||||
struct timeabs *timestamp,
|
||||
enum channel_state old_state,
|
||||
enum channel_state new_state,
|
||||
enum state_change cause,
|
||||
char *message);
|
||||
|
||||
/**
|
||||
* wallet_peer_delete -- After no more channels in peer, forget about it
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user