mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
wallet: Add primitives to annotate a transaction input and output
We'll slowly migrate from the tx annotations to the input and output we are interested in.
This commit is contained in:
parent
2bfe9ffdf8
commit
3d14c18074
@ -2862,6 +2862,39 @@ void wallet_transaction_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
}
|
||||
}
|
||||
|
||||
static void wallet_annotation_add(struct wallet *w, const struct bitcoin_txid *txid, int num,
|
||||
enum wallet_tx_annotation_type annotation_type, enum wallet_tx_type type, u64 channel)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
|
||||
stmt = db_prepare_v2(
|
||||
w->db,SQL("INSERT INTO transaction_annotations "
|
||||
"(txid, idx, location, type, channel) "
|
||||
"VALUES (?, ?, ?, ?, ?) ON CONFLICT(txid,idx) DO NOTHING;"));
|
||||
|
||||
db_bind_txid(stmt, 0, txid);
|
||||
db_bind_int(stmt, 1, num);
|
||||
db_bind_int(stmt, 2, annotation_type);
|
||||
db_bind_int(stmt, 3, type);
|
||||
if (channel != 0)
|
||||
db_bind_u64(stmt, 4, channel);
|
||||
else
|
||||
db_bind_null(stmt, 4);
|
||||
db_exec_prepared_v2(take(stmt));
|
||||
}
|
||||
|
||||
void wallet_annotate_txout(struct wallet *w, const struct bitcoin_txid *txid,
|
||||
int outnum, enum wallet_tx_type type, u64 channel)
|
||||
{
|
||||
wallet_annotation_add(w, txid, outnum, OUTPUT_ANNOTATION, type, channel);
|
||||
}
|
||||
|
||||
void wallet_annotate_txin(struct wallet *w, const struct bitcoin_txid *txid,
|
||||
int innum, enum wallet_tx_type type, u64 channel)
|
||||
{
|
||||
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)
|
||||
|
@ -1055,6 +1055,12 @@ void wallet_utxoset_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
void wallet_transaction_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
const u32 blockheight, const u32 txindex);
|
||||
|
||||
void wallet_annotate_txout(struct wallet *w, const struct bitcoin_txid *txid,
|
||||
int outnum, enum wallet_tx_type type, u64 channel);
|
||||
|
||||
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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user