Skip to content

Commit

Permalink
listtransactions: get rid of per-tx type annotations.
Browse files Browse the repository at this point in the history
We didn't actually populate them properly, and the real annotations
are on inputs and outputs.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-EXPERIMENTAL: JSON-RPC: `listtransactions` `channel` and `type` field removed at top level.
  • Loading branch information
rustyrussell authored and endothermicdev committed Jan 30, 2023
1 parent 578f075 commit 611795b
Show file tree
Hide file tree
Showing 25 changed files with 23 additions and 235 deletions.
1 change: 0 additions & 1 deletion cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions contrib/pyln-testing/pyln/testing/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,6 @@ def listtransactions_transactions2py(m):
"rawtx": hexlify(m.rawtx), # PrimitiveField in generate_composite
"blockheight": m.blockheight, # PrimitiveField in generate_composite
"txindex": m.txindex, # PrimitiveField in generate_composite
"type": [str(i) for i in m.type], # ArrayField[composite] in generate_composite
"channel": m.channel, # PrimitiveField in generate_composite
"locktime": m.locktime, # PrimitiveField in generate_composite
"version": m.version, # PrimitiveField in generate_composite
"inputs": [listtransactions_transactions_inputs2py(i) for i in m.inputs], # ArrayField[composite] in generate_composite
Expand Down
5 changes: 1 addition & 4 deletions doc/lightning-listtransactions.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ On success, an object containing **transactions** is returned. It is an array o
- **scriptPubKey** (hex): the scriptPubKey
- **type** (string, optional): the purpose of this output (*EXPERIMENTAL\_FEATURES* only) (one of "theirs", "deposit", "withdraw", "channel\_funding", "channel\_mutual\_close", "channel\_unilateral\_close", "channel\_sweep", "channel\_htlc\_success", "channel\_htlc\_timeout", "channel\_penalty", "channel\_unilateral\_cheat")
- **channel** (short\_channel\_id, optional): the channel this output is associated with (*EXPERIMENTAL\_FEATURES* only)
- **type** (array of strings, optional):
- Reason we care about this transaction (*EXPERIMENTAL\_FEATURES* only) (one of "theirs", "deposit", "withdraw", "channel\_funding", "channel\_mutual\_close", "channel\_unilateral\_close", "channel\_sweep", "channel\_htlc\_success", "channel\_htlc\_timeout", "channel\_penalty", "channel\_unilateral\_cheat")
- **channel** (short\_channel\_id, optional): the channel this transaction is associated with (*EXPERIMENTAL\_FEATURES* only)

[comment]: # (GENERATE-FROM-SCHEMA-END)

Expand Down Expand Up @@ -106,4 +103,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:450383460036860bfeb65fac98582b4c075d9b6c8df326f22ee1aabde7980d74)
[comment]: # ( SHA256STAMP:4820c0c2f399fd5bec1a960bdc731c131a0fb019f7506df3053ae1bc08705845)
2 changes: 1 addition & 1 deletion doc/lightning-preapproveinvoice.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:735dd61146b04745f1e884037ead662a386fec2c41e2de1a8698d6bb03f63540)
[comment]: # ( SHA256STAMP:ec98523e094209b75eeeb620d8f2a64409dafe6ba21baf3a89ade514b285d202)
2 changes: 1 addition & 1 deletion doc/lightning-preapprovekeysend.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:735dd61146b04745f1e884037ead662a386fec2c41e2de1a8698d6bb03f63540)
[comment]: # ( SHA256STAMP:ec98523e094209b75eeeb620d8f2a64409dafe6ba21baf3a89ade514b285d202)
24 changes: 0 additions & 24 deletions doc/schemas/listtransactions.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,6 @@
"type": "u32",
"description": "the transaction number within the block"
},
"type": {
"type": "array",
"items": {
"type": "string",
"enum": [
"theirs",
"deposit",
"withdraw",
"channel_funding",
"channel_mutual_close",
"channel_unilateral_close",
"channel_sweep",
"channel_htlc_success",
"channel_htlc_timeout",
"channel_penalty",
"channel_unilateral_cheat"
],
"description": "Reason we care about this transaction (*EXPERIMENTAL_FEATURES* only)"
}
},
"channel": {
"type": "short_channel_id",
"description": "the channel this transaction is associated with (*EXPERIMENTAL_FEATURES* only)"
},
"locktime": {
"type": "u32",
"description": "The nLocktime for this tx"
Expand Down
6 changes: 1 addition & 5 deletions lightningd/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ struct channel *new_unsaved_channel(struct peer *peer,
channel->shutdown_scriptpubkey[REMOTE] = NULL;
channel->last_was_revoke = false;
channel->last_sent_commit = NULL;
channel->last_tx_type = TX_UNKNOWN;

channel->feerate_base = feerate_base;
channel->feerate_ppm = feerate_ppm;
Expand Down Expand Up @@ -452,7 +451,6 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
channel->last_tx = tal_steal(channel, last_tx);
if (channel->last_tx) {
channel->last_tx->chainparams = chainparams;
channel->last_tx_type = TX_UNKNOWN;
}
channel->last_sig = *last_sig;
channel->last_htlc_sigs = tal_steal(channel, last_htlc_sigs);
Expand Down Expand Up @@ -723,14 +721,12 @@ struct channel *find_channel_by_alias(const struct peer *peer,

void channel_set_last_tx(struct channel *channel,
struct bitcoin_tx *tx,
const struct bitcoin_signature *sig,
enum wallet_tx_type txtypes)
const struct bitcoin_signature *sig)
{
assert(tx->chainparams);
channel->last_sig = *sig;
tal_free(channel->last_tx);
channel->last_tx = tal_steal(channel, tx);
channel->last_tx_type = txtypes;
}

void channel_set_state(struct channel *channel,
Expand Down
4 changes: 1 addition & 3 deletions lightningd/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ struct channel {

/* Last tx they gave us. */
struct bitcoin_tx *last_tx;
enum wallet_tx_type last_tx_type;
struct bitcoin_signature last_sig;
const struct bitcoin_signature *last_htlc_sigs;

Expand Down Expand Up @@ -435,8 +434,7 @@ struct channel *find_channel_by_alias(const struct peer *peer,

void channel_set_last_tx(struct channel *channel,
struct bitcoin_tx *tx,
const struct bitcoin_signature *sig,
enum wallet_tx_type type);
const struct bitcoin_signature *sig);

static inline bool channel_can_add_htlc(const struct channel *channel)
{
Expand Down
6 changes: 2 additions & 4 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,10 +1067,8 @@ struct command_result *cancel_channel_before_broadcast(struct command *cmd,

/* Check if we broadcast the transaction. (We store the transaction
* type into DB before broadcast). */
enum wallet_tx_type type;
if (wallet_transaction_type(cmd->ld->wallet,
&cancel_channel->funding.txid,
&type))
if (wallet_transaction_get(tmpctx, cmd->ld->wallet,
&cancel_channel->funding.txid))
return command_fail(cmd, FUNDING_CANCEL_NOT_SAFE,
"Has the funding transaction been"
" broadcast? Please use `close` or"
Expand Down
2 changes: 1 addition & 1 deletion lightningd/closing_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static void peer_received_closing_signature(struct channel *channel,
}

if (closing_fee_is_acceptable(ld, channel, tx)) {
channel_set_last_tx(channel, tx, &sig, TX_CHANNEL_CLOSE);
channel_set_last_tx(channel, tx, &sig);
wallet_channel_save(ld->wallet, channel);
}

Expand Down
4 changes: 1 addition & 3 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,8 +1149,7 @@ wallet_update_channel(struct lightningd *ld,

channel_set_last_tx(channel,
tal_steal(channel, remote_commit),
remote_commit_sig,
TX_CHANNEL_UNILATERAL);
remote_commit_sig);

/* Update in database */
wallet_channel_save(ld->wallet, channel);
Expand Down Expand Up @@ -1238,7 +1237,6 @@ wallet_commit_channel(struct lightningd *ld,

channel->last_tx = tal_steal(channel, remote_commit);
channel->last_sig = *remote_commit_sig;
channel->last_tx_type = TX_CHANNEL_UNILATERAL;

channel->channel_info = *channel_info;
channel->fee_states = new_fee_states(channel,
Expand Down
6 changes: 1 addition & 5 deletions lightningd/onchain_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,16 @@ static void handle_onchain_broadcast_tx(struct channel *channel,
{
struct bitcoin_tx *tx;
struct wallet *w = channel->peer->ld->wallet;
struct bitcoin_txid txid;
enum wallet_tx_type type;
bool is_rbf;

if (!fromwire_onchaind_broadcast_tx(msg, msg, &tx, &type, &is_rbf)) {
if (!fromwire_onchaind_broadcast_tx(msg, msg, &tx, &is_rbf)) {
channel_internal_error(channel, "Invalid onchain_broadcast_tx");
return;
}

tx->chainparams = chainparams;

bitcoin_txid(tx, &txid);
wallet_transaction_add(w, tx->wtx, 0, 0);
wallet_transaction_annotate(w, &txid, type, channel->dbid);

/* We don't really care if it fails, we'll respond via watch. */
/* If the onchaind signals this as RBF-able, then we also
Expand Down
6 changes: 1 addition & 5 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ static void sign_and_send_last(struct lightningd *ld,
sign_last_tx(channel, last_tx, last_sig);
bitcoin_txid(last_tx, &txid);
wallet_transaction_add(ld->wallet, last_tx->wtx, 0, 0);
wallet_transaction_annotate(ld->wallet, &txid,
channel->last_tx_type,
channel->dbid);

/* Keep broadcasting until we say stop (can fail due to dup,
* if they beat us to the broadcast). */
Expand Down Expand Up @@ -1739,8 +1736,7 @@ static void update_channel_from_inflight(struct lightningd *ld,
psbt_copy = clone_psbt(channel, inflight->last_tx->psbt);
channel_set_last_tx(channel,
bitcoin_tx_with_psbt(channel, psbt_copy),
&inflight->last_sig,
TX_CHANNEL_UNILATERAL);
&inflight->last_sig);

/* Update the reserve */
channel_update_reserve(channel,
Expand Down
2 changes: 1 addition & 1 deletion lightningd/peer_htlcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,7 @@ static bool peer_save_commitsig_received(struct channel *channel, u64 commitnum,
channel->next_index[LOCAL]++;

/* Update channel->last_sig and channel->last_tx before saving to db */
channel_set_last_tx(channel, tx, commit_sig, TX_CHANNEL_UNILATERAL);
channel_set_last_tx(channel, tx, commit_sig);

return true;
}
Expand Down
8 changes: 1 addition & 7 deletions lightningd/test/run-invoice-select-inchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ u32 channel_last_funding_feerate(const struct channel *channel UNNEEDED)
/* Generated stub for channel_set_last_tx */
void channel_set_last_tx(struct channel *channel UNNEEDED,
struct bitcoin_tx *tx UNNEEDED,
const struct bitcoin_signature *sig UNNEEDED,
enum wallet_tx_type type UNNEEDED)
const struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "channel_set_last_tx called!\n"); abort(); }
/* Generated stub for channel_state_name */
const char *channel_state_name(const struct channel *channel UNNEEDED)
Expand Down Expand Up @@ -946,11 +945,6 @@ struct amount_msat wallet_total_forward_fees(struct wallet *w UNNEEDED)
void wallet_transaction_add(struct wallet *w UNNEEDED, const struct wally_tx *tx UNNEEDED,
const u32 blockheight UNNEEDED, const u32 txindex UNNEEDED)
{ fprintf(stderr, "wallet_transaction_add called!\n"); abort(); }
/* Generated stub for wallet_transaction_annotate */
void wallet_transaction_annotate(struct wallet *w UNNEEDED,
const struct bitcoin_txid *txid UNNEEDED,
enum wallet_tx_type type UNNEEDED, u64 channel_id UNNEEDED)
{ fprintf(stderr, "wallet_transaction_annotate called!\n"); abort(); }
/* Generated stub for wallet_transaction_locate */
struct txlocator *wallet_transaction_locate(const tal_t *ctx UNNEEDED, struct wallet *w UNNEEDED,
const struct bitcoin_txid *txid UNNEEDED)
Expand Down
47 changes: 2 additions & 45 deletions onchaind/onchaind.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,43 +1018,6 @@ static void ignore_output(struct tracked_output *out)
out->resolved->tx_type = SELF;
}

static enum wallet_tx_type onchain_txtype_to_wallet_txtype(enum tx_type t)
{
switch (t) {
case FUNDING_TRANSACTION:
return TX_CHANNEL_FUNDING;
case MUTUAL_CLOSE:
return TX_CHANNEL_CLOSE;
case OUR_UNILATERAL:
return TX_CHANNEL_UNILATERAL;
case THEIR_HTLC_FULFILL_TO_US:
case OUR_HTLC_SUCCESS_TX:
return TX_CHANNEL_HTLC_SUCCESS;
case OUR_HTLC_TIMEOUT_TO_US:
case OUR_HTLC_TIMEOUT_TX:
return TX_CHANNEL_HTLC_TIMEOUT;
case OUR_DELAYED_RETURN_TO_WALLET:
case SELF:
return TX_CHANNEL_SWEEP;
case OUR_PENALTY_TX:
return TX_CHANNEL_PENALTY;
case THEIR_DELAYED_CHEAT:
return TX_CHANNEL_CHEAT | TX_THEIRS;
case THEIR_UNILATERAL:
case UNKNOWN_UNILATERAL:
case THEIR_REVOKED_UNILATERAL:
return TX_CHANNEL_UNILATERAL | TX_THEIRS;
case THEIR_HTLC_TIMEOUT_TO_THEM:
return TX_CHANNEL_HTLC_TIMEOUT | TX_THEIRS;
case OUR_HTLC_FULFILL_TO_THEM:
return TX_CHANNEL_HTLC_SUCCESS | TX_THEIRS;
case IGNORING_TINY_PAYMENT:
case UNKNOWN_TXTYPE:
return TX_UNKNOWN;
}
abort();
}

/** proposal_is_rbfable
*
* @brief returns true if the given proposal
Expand Down Expand Up @@ -1141,8 +1104,6 @@ static void proposal_should_rbf(struct tracked_output *out)

/* Broadcast the transaction. */
if (tx) {
enum wallet_tx_type wtt;

status_debug("Broadcasting RBF %s (%s) to resolve %s/%s "
"depth=%"PRIu32"",
tx_type_name(out->proposal->tx_type),
Expand All @@ -1151,11 +1112,9 @@ static void proposal_should_rbf(struct tracked_output *out)
output_type_name(out->output_type),
depth);

wtt = onchain_txtype_to_wallet_txtype(out->proposal->tx_type);
wire_sync_write(REQ_FD,
take(towire_onchaind_broadcast_tx(NULL, tx,
wtt,
true)));
true)));
}
}

Expand Down Expand Up @@ -1186,9 +1145,7 @@ static void proposal_meets_depth(struct tracked_output *out)
wire_sync_write(
REQ_FD,
take(towire_onchaind_broadcast_tx(
NULL, out->proposal->tx,
onchain_txtype_to_wallet_txtype(out->proposal->tx_type),
is_rbf)));
NULL, out->proposal->tx, is_rbf)));

/* Don't wait for this if we're ignoring the tiny payment. */
if (out->proposal->tx_type == IGNORING_TINY_PAYMENT) {
Expand Down
1 change: 0 additions & 1 deletion onchaind/onchaind_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ msgdata,onchaind_htlcs,tell_immediately,bool,num_htlcs
# it with a higher fee.
msgtype,onchaind_broadcast_tx,5003
msgdata,onchaind_broadcast_tx,tx,bitcoin_tx,
msgdata,onchaind_broadcast_tx,type,enum wallet_tx_type,
msgdata,onchaind_broadcast_tx,is_rbf,bool,

# master->onchaind: Notifier that an output has been spent by input_num of tx.
Expand Down
2 changes: 1 addition & 1 deletion onchaind/test/run-grind_feerate-bug.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ u8 *towire_onchaind_annotate_txin(const tal_t *ctx UNNEEDED, const struct bitcoi
u8 *towire_onchaind_annotate_txout(const tal_t *ctx UNNEEDED, const struct bitcoin_outpoint *outpoint UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_annotate_txout called!\n"); abort(); }
/* Generated stub for towire_onchaind_broadcast_tx */
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, enum wallet_tx_type type UNNEEDED, bool is_rbf UNNEEDED)
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, bool is_rbf UNNEEDED)
{ fprintf(stderr, "towire_onchaind_broadcast_tx called!\n"); abort(); }
/* Generated stub for towire_onchaind_dev_memleak_reply */
u8 *towire_onchaind_dev_memleak_reply(const tal_t *ctx UNNEEDED, bool leak UNNEEDED)
Expand Down
2 changes: 1 addition & 1 deletion onchaind/test/run-grind_feerate.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ u8 *towire_onchaind_annotate_txin(const tal_t *ctx UNNEEDED, const struct bitcoi
u8 *towire_onchaind_annotate_txout(const tal_t *ctx UNNEEDED, const struct bitcoin_outpoint *outpoint UNNEEDED, enum wallet_tx_type type UNNEEDED)
{ fprintf(stderr, "towire_onchaind_annotate_txout called!\n"); abort(); }
/* Generated stub for towire_onchaind_broadcast_tx */
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, enum wallet_tx_type type UNNEEDED, bool is_rbf UNNEEDED)
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, bool is_rbf UNNEEDED)
{ fprintf(stderr, "towire_onchaind_broadcast_tx called!\n"); abort(); }
/* Generated stub for towire_onchaind_dev_memleak_reply */
u8 *towire_onchaind_dev_memleak_reply(const tal_t *ctx UNNEEDED, bool leak UNNEEDED)
Expand Down
2 changes: 2 additions & 0 deletions wallet/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ static struct migration dbmigrations[] = {
/* remote signatures for channel announcement */
{SQL("ALTER TABLE channels ADD remote_ann_node_sig BLOB;"), NULL},
{SQL("ALTER TABLE channels ADD remote_ann_bitcoin_sig BLOB;"), NULL},
/* FIXME: We now use the transaction_annotations table to type each
* input and output instead of type and channel_id! */
/* Additional information for transaction tracking and listing */
{SQL("ALTER TABLE transactions ADD type BIGINT;"), NULL},
/* Not a foreign key on purpose since we still delete channels from
Expand Down
Loading

0 comments on commit 611795b

Please sign in to comment.