diff --git a/cln-grpc/proto/node.proto b/cln-grpc/proto/node.proto index dca6d7e71..b7386cb25 100644 --- a/cln-grpc/proto/node.proto +++ b/cln-grpc/proto/node.proto @@ -744,7 +744,6 @@ message ListtransactionsTransactions { bytes rawtx = 2; uint32 blockheight = 3; uint32 txindex = 4; - optional string channel = 6; uint32 locktime = 7; uint32 version = 8; repeated ListtransactionsTransactionsInputs inputs = 9; diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index c8096ae28..df5bb8e7d 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -632,7 +632,6 @@ impl From for pb::ListtransactionsTrans rawtx: hex::decode(&c.rawtx).unwrap(), // Rule #2 for type hex blockheight: c.blockheight, // Rule #2 for type u32 txindex: c.txindex, // Rule #2 for type u32 - channel: c.channel.map(|v| v.to_string()), // Rule #2 for type short_channel_id? locktime: c.locktime, // Rule #2 for type u32 version: c.version, // Rule #2 for type u32 inputs: c.inputs.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactionsInputs diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index 38601d811..45ab1e82e 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -2632,8 +2632,6 @@ pub mod responses { pub rawtx: String, pub blockheight: u32, pub txindex: u32, - #[serde(skip_serializing_if = "Option::is_none")] - pub channel: Option, pub locktime: u32, pub version: u32, pub inputs: Vec, diff --git a/contrib/pyln-testing/pyln/testing/grpc2py.py b/contrib/pyln-testing/pyln/testing/grpc2py.py index 482dc822d..5a4bdc1a3 100644 --- a/contrib/pyln-testing/pyln/testing/grpc2py.py +++ b/contrib/pyln-testing/pyln/testing/grpc2py.py @@ -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 diff --git a/doc/lightning-listtransactions.7.md b/doc/lightning-listtransactions.7.md index 76619a0a6..a0f8e72bd 100644 --- a/doc/lightning-listtransactions.7.md +++ b/doc/lightning-listtransactions.7.md @@ -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) @@ -106,4 +103,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:450383460036860bfeb65fac98582b4c075d9b6c8df326f22ee1aabde7980d74) +[comment]: # ( SHA256STAMP:4820c0c2f399fd5bec1a960bdc731c131a0fb019f7506df3053ae1bc08705845) diff --git a/doc/lightning-preapproveinvoice.7.md b/doc/lightning-preapproveinvoice.7.md index c39d96dca..e4ff52291 100644 --- a/doc/lightning-preapproveinvoice.7.md +++ b/doc/lightning-preapproveinvoice.7.md @@ -48,4 +48,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:735dd61146b04745f1e884037ead662a386fec2c41e2de1a8698d6bb03f63540) +[comment]: # ( SHA256STAMP:ec98523e094209b75eeeb620d8f2a64409dafe6ba21baf3a89ade514b285d202) diff --git a/doc/lightning-preapprovekeysend.7.md b/doc/lightning-preapprovekeysend.7.md index 533041818..0f0f776f3 100644 --- a/doc/lightning-preapprovekeysend.7.md +++ b/doc/lightning-preapprovekeysend.7.md @@ -58,4 +58,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:735dd61146b04745f1e884037ead662a386fec2c41e2de1a8698d6bb03f63540) +[comment]: # ( SHA256STAMP:ec98523e094209b75eeeb620d8f2a64409dafe6ba21baf3a89ade514b285d202) diff --git a/doc/schemas/listtransactions.schema.json b/doc/schemas/listtransactions.schema.json index 3c34ba896..e0f75bd66 100644 --- a/doc/schemas/listtransactions.schema.json +++ b/doc/schemas/listtransactions.schema.json @@ -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" diff --git a/lightningd/channel.c b/lightningd/channel.c index ec697518d..5687269bd 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -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; @@ -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); @@ -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, diff --git a/lightningd/channel.h b/lightningd/channel.h index 9a31157c6..381794cff 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -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; @@ -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) { diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 7bef2284f..94dc7e483 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -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" diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c index 03b6565ad..73ccaf835 100644 --- a/lightningd/closing_control.c +++ b/lightningd/closing_control.c @@ -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); } diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 428c1ede1..1743186bf 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -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); @@ -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, diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index e881d7a77..0a7e6f3ff 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -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 diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index dfb75e795..a084ded4f 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -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). */ @@ -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, diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 2bb9531fe..c62cb669a 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -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; } diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 93d624d18..2e265e827 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -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) @@ -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) diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index 8c9e971d7..e440bddcc 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -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 @@ -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), @@ -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))); } } @@ -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) { diff --git a/onchaind/onchaind_wire.csv b/onchaind/onchaind_wire.csv index f6f3776a3..1f891b663 100644 --- a/onchaind/onchaind_wire.csv +++ b/onchaind/onchaind_wire.csv @@ -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. diff --git a/onchaind/test/run-grind_feerate-bug.c b/onchaind/test/run-grind_feerate-bug.c index 0c069752d..e9d669156 100644 --- a/onchaind/test/run-grind_feerate-bug.c +++ b/onchaind/test/run-grind_feerate-bug.c @@ -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) diff --git a/onchaind/test/run-grind_feerate.c b/onchaind/test/run-grind_feerate.c index 7eb8d6516..99e8ec149 100644 --- a/onchaind/test/run-grind_feerate.c +++ b/onchaind/test/run-grind_feerate.c @@ -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) diff --git a/wallet/db.c b/wallet/db.c index 4a45167f5..927e5dd11 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -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 diff --git a/wallet/wallet.c b/wallet/wallet.c index 1424dfc3b..6bfed095d 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -4133,66 +4133,6 @@ void wallet_annotate_txin(struct wallet *w, const struct bitcoin_txid *txid, wallet_annotation_add(w, txid, innum, INPUT_ANNOTATION, type, channel); } -void wallet_transaction_annotate(struct wallet *w, - const struct bitcoin_txid *txid, enum wallet_tx_type type, - u64 channel_id) -{ - struct db_stmt *stmt = db_prepare_v2( - w->db, SQL("SELECT type, channel_id FROM transactions WHERE id=?")); - db_bind_txid(stmt, 0, txid); - db_query_prepared(stmt); - - if (!db_step(stmt)) - fatal("Attempting to annotate a transaction we don't have: %s", - type_to_string(tmpctx, struct bitcoin_txid, txid)); - - if (!db_col_is_null(stmt, "type")) - type |= db_col_u64(stmt, "type"); - - if (channel_id == 0 && !db_col_is_null(stmt, "channel_id")) - channel_id = db_col_u64(stmt, "channel_id"); - else - db_col_ignore(stmt, "channel_id"); - - tal_free(stmt); - - stmt = db_prepare_v2(w->db, SQL("UPDATE transactions " - "SET type = ?" - ", channel_id = ? " - "WHERE id = ?")); - - db_bind_u64(stmt, 0, type); - - if (channel_id) - db_bind_int(stmt, 1, channel_id); - else - db_bind_null(stmt, 1); - - db_bind_txid(stmt, 2, txid); - db_exec_prepared_v2(take(stmt)); -} - -bool wallet_transaction_type(struct wallet *w, const struct bitcoin_txid *txid, - enum wallet_tx_type *type) -{ - struct db_stmt *stmt = db_prepare_v2(w->db, SQL("SELECT type FROM transactions WHERE id=?")); - db_bind_sha256(stmt, 0, &txid->shad.sha); - db_query_prepared(stmt); - - if (!db_step(stmt)) { - tal_free(stmt); - return false; - } - - if (!db_col_is_null(stmt, "type")) - *type = db_col_u64(stmt, "type"); - else - *type = 0; - - tal_free(stmt); - return true; -} - struct bitcoin_tx *wallet_transaction_get(const tal_t *ctx, struct wallet *w, const struct bitcoin_txid *txid) { @@ -4794,8 +4734,6 @@ struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t ", t.rawtx" ", t.blockheight" ", t.txindex" - ", t.type as txtype" - ", c2.scid as txchan" ", a.location" ", a.idx as ann_idx" ", a.type as annotation_type" @@ -4803,8 +4741,7 @@ struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t " 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) " + " channels c ON (a.channel = c.id) " "ORDER BY t.blockheight, t.txindex ASC")); db_query_prepared(stmt); @@ -4836,16 +4773,6 @@ struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t cur->blockheight = 0; cur->txindex = 0; } - if (!db_col_is_null(stmt, "txtype")) - cur->annotation.type - = db_col_u64(stmt, "txtype"); - else - cur->annotation.type = 0; - if (!db_col_is_null(stmt, "txchan")) - db_col_scid(stmt, "txchan", &cur->annotation.channel); - else - cur->annotation.channel.u64 = 0; - cur->output_annotations = tal_arrz(txs, struct tx_annotation, cur->tx->wtx->num_outputs); cur->input_annotations = tal_arrz(txs, struct tx_annotation, cur->tx->wtx->num_inputs); } diff --git a/wallet/wallet.h b/wallet/wallet.h index fe84c6ffe..537580a3d 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -408,8 +408,6 @@ struct wallet_transaction { /* Fully parsed transaction */ const struct bitcoin_tx *tx; - struct tx_annotation annotation; - /* tal_arr containing the annotation types, if any, for the respective * inputs and outputs. 0 if there are no annotations for the * element. */ @@ -1291,28 +1289,6 @@ void wallet_annotate_txout(struct wallet *w, void wallet_annotate_txin(struct wallet *w, const struct bitcoin_txid *txid, int innum, enum wallet_tx_type type, u64 channel); -/** - * Annotate a transaction in the DB with its type and channel referemce. - * - * We add transactions when filtering the block, but often know its type only - * when we trigger the txwatches, at which point we've already discarded the - * full transaction. This function can be used to annotate the transactions - * after the fact with a channel number for grouping and a type for filtering. - */ -void wallet_transaction_annotate(struct wallet *w, - const struct bitcoin_txid *txid, - enum wallet_tx_type type, u64 channel_id); - -/** - * Get the type of a transaction we are watching by its - * txid. - * - * Returns false if the transaction was not stored in DB. - * Returns true if the transaction exists and sets the `type` parameter. - */ -bool wallet_transaction_type(struct wallet *w, const struct bitcoin_txid *txid, - enum wallet_tx_type *type); - /** * Get the transaction from the database * diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 4292781ac..9c9dc22ee 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -1,6 +1,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -483,28 +484,18 @@ struct { {TX_CHANNEL_HTLC_TIMEOUT, "channel_htlc_timeout"}, {TX_CHANNEL_PENALTY, "channel_penalty"}, {TX_CHANNEL_CHEAT, "channel_unilateral_cheat"}, - {0, NULL} }; #if EXPERIMENTAL_FEATURES static const char *txtype_to_string(enum wallet_tx_type t) { - for (size_t i = 0; wallet_tx_type_display_names[i].name != NULL; i++) + for (size_t i = 0; i < ARRAY_SIZE(wallet_tx_type_display_names); i++) if (t == wallet_tx_type_display_names[i].t) return wallet_tx_type_display_names[i].name; return NULL; } - -static void json_add_txtypes(struct json_stream *result, const char *fieldname, enum wallet_tx_type value) -{ - json_array_start(result, fieldname); - for (size_t i = 0; wallet_tx_type_display_names[i].name != NULL; i++) { - if (value & wallet_tx_type_display_names[i].t) - json_add_string(result, NULL, wallet_tx_type_display_names[i].name); - } - json_array_end(result); -} #endif + static void json_transaction_details(struct json_stream *response, const struct wallet_transaction *tx) { @@ -515,13 +506,6 @@ static void json_transaction_details(struct json_stream *response, json_add_hex_talarr(response, "rawtx", tx->rawtx); json_add_num(response, "blockheight", tx->blockheight); json_add_num(response, "txindex", tx->txindex); -#if EXPERIMENTAL_FEATURES - if (tx->annotation.type != 0) - json_add_txtypes(response, "type", tx->annotation.type); - - if (tx->annotation.channel.u64 != 0) - json_add_short_channel_id(response, "channel", &tx->annotation.channel); -#endif json_add_u32(response, "locktime", wtx->locktime); json_add_u32(response, "version", wtx->version);