-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bkpr: add two custom notifications that we listen for #7258
bkpr: add two custom notifications that we listen for #7258
Conversation
044807c
to
109da8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked inside the CI failure and I think I found the problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
I left a comment
|
||
See the doc/PLUGINS.md#coin_movement section on the message that CLN emits for us to process. | ||
|
||
// FIXME: add more detailed documenation for how bookkeeper works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// FIXME: add more detailed documenation for how bookkeeper works. | |
// FIXME: add more detailed documenation for how bookkeeper works. |
This can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should stay until there's more detailed documentation, currently the README only describes how the 2 new event types work. But up to @niftynei really
plugins/bkpr/recorder.c
Outdated
@@ -1935,11 +1935,12 @@ char *maybe_update_onchain_fees(const tal_t *ctx, struct db *db, | |||
} | |||
|
|||
void maybe_closeout_external_deposits(struct db *db, | |||
struct chain_event *ev) | |||
struct bitcoin_txid *txid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct bitcoin_txid *txid, | |
const struct bitcoin_txid *txid, |
usually we use const
here
plugins/bkpr/recorder.h
Outdated
@@ -208,7 +208,9 @@ void add_payment_hash_desc(struct db *db, | |||
* | |||
* This method updates the blockheight on these events to the | |||
* height an input was spent into */ | |||
void maybe_closeout_external_deposits(struct db *db, struct chain_event *ev); | |||
void maybe_closeout_external_deposits(struct db *db, | |||
struct bitcoin_txid *txid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor change, I think the first commit is overzealous, and I'd like the fixup folded so we don't have an intermediary commit using type_to_strings which doesn't compile.
plugins/bkpr/recorder.c
Outdated
const struct account *acct, | ||
struct chain_event *e) | ||
{ | ||
struct db_stmt *stmt; | ||
|
||
/* We're responsible for de-duping chain events! */ | ||
if (find_chain_event(e, db, acct, | ||
if (find_chain_event(ctx, db, acct, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should actually be tmpctx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And ctx arg is unnecessary...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow yeah, lots of gymnastics on this one. fixing..
plugins/bkpr/recorder.c
Outdated
@@ -2040,7 +2041,7 @@ bool log_chain_event(struct db *db, | |||
db_exec_prepared_v2(stmt); | |||
e->db_id = db_last_insert_id_v2(stmt); | |||
e->acct_db_id = acct->db_id; | |||
e->acct_name = tal_strdup(e, acct->name); | |||
e->acct_name = tal_strdup(ctx, acct->name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack.
lightningd/plugin.c
Outdated
@@ -2415,7 +2415,7 @@ bool plugin_single_notify(struct plugin *p, | |||
const struct jsonrpc_notification *n TAKES) | |||
{ | |||
bool interested; | |||
if (plugin_subscriptions_contains(p, n->method)) { | |||
if (p->plugin_state == INIT_COMPLETE && plugin_subscriptions_contains(p, n->method)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧡
It might be nice to let the bookkeeper keep track of external accounts as well as the internal onchain wallet? To this end, we add some new custom notifications, which the bookkeeper will ingest and add to its ledger. Suggested-By: @chrisguida Changelog-Added: PLUGINS: `bookkeeper` now listens for two custom events: `utxo_deposit` and `utxo_spend`. This allows for 3rd party plugins to send onchain coin events to the `bookkeeper`. See the new plugins/bkpr/README.md for details on how these work!
e5c2d2d
to
d48ea39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments have been addressed and fixed up as requested!
plugins/bkpr/bookkeeper.c
Outdated
@@ -1724,10 +1724,10 @@ static struct command_result *json_utxo_deposit(struct command *cmd, const char | |||
|
|||
plugin_log(cmd->plugin, LOG_DBG, "%s (%s|%s) %s -%s %"PRIu64" %d %s", | |||
move_tag, ev.tag, ev.acct_name, | |||
type_to_string(tmpctx, struct amount_msat, &ev.credit), | |||
type_to_string(tmpctx, struct amount_msat, &ev.debit), | |||
fmt_amount_msat(tmpctx, ev.credit), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as prior, this should be squashed into the original commit that makes these changes.
plugins/bkpr/recorder.c
Outdated
const struct account *acct, | ||
struct chain_event *e) | ||
{ | ||
struct db_stmt *stmt; | ||
|
||
/* We're responsible for de-duping chain events! */ | ||
if (find_chain_event(e, db, acct, | ||
if (find_chain_event(ctx, db, acct, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow yeah, lots of gymnastics on this one. fixing..
plugins/bkpr/recorder.c
Outdated
@@ -2040,7 +2041,7 @@ bool log_chain_event(struct db *db, | |||
db_exec_prepared_v2(stmt); | |||
e->db_id = db_last_insert_id_v2(stmt); | |||
e->acct_db_id = acct->db_id; | |||
e->acct_name = tal_strdup(e, acct->name); | |||
e->acct_name = tal_strdup(ctx, acct->name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack.
plugins/bkpr/recorder.h
Outdated
@@ -208,7 +208,9 @@ void add_payment_hash_desc(struct db *db, | |||
* | |||
* This method updates the blockheight on these events to the | |||
* height an input was spent into */ | |||
void maybe_closeout_external_deposits(struct db *db, struct chain_event *ev); | |||
void maybe_closeout_external_deposits(struct db *db, | |||
struct bitcoin_txid *txid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack.
Thanks for the fixups @niftynei! @rustyrussell I think this one should be ready to go now :) |
ElementsProject/lightning#7258 finally merged, so we need to switch to the new more consistent tag names and use the elementsproject fork instead of niftynei There are also some changes required for the new startup_regtest script.
ElementsProject/lightning#7258 finally merged, so we need to switch to the new more consistent tag names and use the elementsproject fork instead of niftynei There are also some changes required for the new startup_regtest script.
ElementsProject/lightning#7258 finally merged, so we need to switch to the new more consistent tag names and use the elementsproject fork instead of niftynei There are also some changes required for the new startup_regtest script.
ElementsProject/lightning#7258 finally merged, so we need to switch to the new more consistent tag names and use the elementsproject fork instead of niftynei There are also some changes required for the new startup_regtest script.
ElementsProject/lightning#7258 finally merged, so we need to switch to the new more consistent tag names and use the elementsproject fork instead of niftynei There are also some changes required for the new startup_regtest script.
ElementsProject/lightning#7258 finally merged, so we need to switch to the new more consistent tag names and use the elementsproject fork instead of niftynei There are also some changes required for the new startup_regtest script.
This PR adds two new event types that
bookkeeper
listens for in order to track on-chain movements in external wallets.This API is currently implemented by the plugin Smaug, which depends on this PR being merged before a release can be cut.