mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
listtransactions: get rid of per-tx type annotations.
We didn't actually populate them properly, and the real annotations are on inputs and outputs. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-EXPERIMENTAL: JSON-RPC: `listtransactions` `channel` and `type` field removed at top level.
This commit is contained in:
parent
578f075407
commit
611795beee
BIN
cln-grpc/proto/node.proto
generated
BIN
cln-grpc/proto/node.proto
generated
Binary file not shown.
BIN
cln-grpc/src/convert.rs
generated
BIN
cln-grpc/src/convert.rs
generated
Binary file not shown.
BIN
cln-rpc/src/model.rs
generated
BIN
cln-rpc/src/model.rs
generated
Binary file not shown.
@ -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
|
||||
|
@ -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: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:450383460036860bfeb65fac98582b4c075d9b6c8df326f22ee1aabde7980d74)
|
||||
[comment]: # ( SHA256STAMP:4820c0c2f399fd5bec1a960bdc731c131a0fb019f7506df3053ae1bc08705845)
|
||||
|
@ -48,4 +48,4 @@ RESOURCES
|
||||
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:735dd61146b04745f1e884037ead662a386fec2c41e2de1a8698d6bb03f63540)
|
||||
[comment]: # ( SHA256STAMP:ec98523e094209b75eeeb620d8f2a64409dafe6ba21baf3a89ade514b285d202)
|
||||
|
@ -58,4 +58,4 @@ RESOURCES
|
||||
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:735dd61146b04745f1e884037ead662a386fec2c41e2de1a8698d6bb03f63540)
|
||||
[comment]: # ( SHA256STAMP:ec98523e094209b75eeeb620d8f2a64409dafe6ba21baf3a89ade514b285d202)
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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,10 +1112,8 @@ 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)));
|
||||
}
|
||||
}
|
||||
@ -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) {
|
||||
|
@ -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.
|
||||
|
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "config.h"
|
||||
#include <bitcoin/base58.h>
|
||||
#include <bitcoin/script.h>
|
||||
#include <ccan/array_size/array_size.h>
|
||||
#include <ccan/cast/cast.h>
|
||||
#include <common/addr.h>
|
||||
#include <common/bech32.h>
|
||||
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user