Skip to content

Commit 3cc095c

Browse files
committed
wallet: make enum wallet_output_type UPPERCASE.
No code change, just following convention. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 28192e3 commit 3cc095c

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

wallet/db.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ void fillin_missing_scriptpubkeys(struct lightningd *ld, struct db *db)
12291229
db_col_ignore(stmt, "peer_id");
12301230
db_col_ignore(stmt, "commitment_point");
12311231
bip32_pubkey(ld, &key, keyindex);
1232-
if (type == p2sh_wpkh) {
1232+
if (type == WALLET_OUTPUT_P2SH_WPKH) {
12331233
u8 *redeemscript = bitcoin_redeem_p2sh_p2wpkh(stmt, &key);
12341234
scriptPubkey = scriptpubkey_p2sh(tmpctx, redeemscript);
12351235
} else

wallet/test/run-wallet.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,12 +1385,12 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
13851385
db_begin_transaction(w->db);
13861386

13871387
/* Should work, it's the first time we add it */
1388-
CHECK_MSG(wallet_add_utxo(w, &u, p2sh_wpkh),
1388+
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2SH_WPKH),
13891389
"wallet_add_utxo failed on first add");
13901390
CHECK_MSG(!wallet_err, wallet_err);
13911391

13921392
/* Should fail, we already have that UTXO */
1393-
CHECK_MSG(!wallet_add_utxo(w, &u, p2sh_wpkh),
1393+
CHECK_MSG(!wallet_add_utxo(w, &u, WALLET_OUTPUT_P2SH_WPKH),
13941394
"wallet_add_utxo succeeded on second add");
13951395
CHECK_MSG(!wallet_err, wallet_err);
13961396

@@ -1404,7 +1404,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
14041404
/* Arbitrarily set scriptpubkey len to 20 */
14051405
u.scriptPubkey = tal_arr(w, u8, 20);
14061406
memset(u.scriptPubkey, 1, 20);
1407-
CHECK_MSG(wallet_add_utxo(w, &u, our_change),
1407+
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_OUR_CHANGE),
14081408
"wallet_add_utxo with close_info");
14091409

14101410
/* Now select them */
@@ -1473,7 +1473,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
14731473
u.blockheight = blockheight;
14741474
u.scriptPubkey = tal_arr(w, u8, 20);
14751475
memset(u.scriptPubkey, 1, 20);
1476-
CHECK_MSG(wallet_add_utxo(w, &u, p2sh_wpkh),
1476+
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2SH_WPKH),
14771477
"wallet_add_utxo with close_info no commitment_point");
14781478
CHECK_MSG(!wallet_err, wallet_err);
14791479

@@ -1555,7 +1555,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
15551555
memset(&u.outpoint, 4, sizeof(u.outpoint));
15561556
u.amount = AMOUNT_SAT(4);
15571557
u.close_info = tal_free(u.close_info);
1558-
CHECK_MSG(wallet_add_utxo(w, &u, p2wpkh),
1558+
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2WPKH),
15591559
"wallet_add_utxo failed, p2wpkh");
15601560

15611561
utxos = tal_arr(w, const struct utxo *, 0);

wallet/wallet.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static struct utxo *wallet_stmt2output(const tal_t *ctx, struct db_stmt *stmt)
363363

364364
utxo->scriptPubkey = db_col_arr(utxo, stmt, "scriptpubkey", u8);
365365
/* FIXME: add p2tr to type? */
366-
if (db_col_int(stmt, "type") == p2sh_wpkh)
366+
if (wallet_output_type_in_db(db_col_int(stmt, "type")) == WALLET_OUTPUT_P2SH_WPKH)
367367
utxo->utxotype = UTXO_P2SH_P2WPKH;
368368
else if (is_p2wpkh(utxo->scriptPubkey, tal_bytelen(utxo->scriptPubkey), NULL))
369369
utxo->utxotype = UTXO_P2WPKH;
@@ -896,7 +896,7 @@ bool wallet_add_onchaind_utxo(struct wallet *w,
896896
db_bind_txid(stmt, &outpoint->txid);
897897
db_bind_int(stmt, outpoint->n);
898898
db_bind_amount_sat(stmt, &amount);
899-
db_bind_int(stmt, wallet_output_type_in_db(p2wpkh));
899+
db_bind_int(stmt, wallet_output_type_in_db(WALLET_OUTPUT_P2WPKH));
900900
db_bind_int(stmt, OUTPUT_STATE_AVAILABLE);
901901
db_bind_int(stmt, 0);
902902
db_bind_u64(stmt, channel->dbid);
@@ -2987,7 +2987,7 @@ static void got_utxo(struct wallet *w,
29872987
notify_chain_mvt(w->ld, mvt);
29882988
}
29892989

2990-
if (!wallet_add_utxo(w, utxo, utxo->utxotype == UTXO_P2SH_P2WPKH ? p2sh_wpkh : our_change)) {
2990+
if (!wallet_add_utxo(w, utxo, utxo->utxotype == UTXO_P2SH_P2WPKH ? WALLET_OUTPUT_P2SH_WPKH : WALLET_OUTPUT_OUR_CHANGE)) {
29912991
/* In case we already know the output, make
29922992
* sure we actually track its
29932993
* blockheight. This can happen when we grab

wallet/wallet.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,34 @@ static inline enum output_status output_status_in_db(enum output_status s)
8282
/* /!\ This is a DB ENUM, please do not change the numbering of any
8383
* already defined elements (adding is ok) /!\ */
8484
enum wallet_output_type {
85-
p2sh_wpkh = 0,
86-
to_local = 1,
87-
htlc_offer = 3,
88-
htlc_recv = 4,
89-
our_change = 5,
90-
p2wpkh = 6
85+
WALLET_OUTPUT_P2SH_WPKH = 0,
86+
WALLET_OUTPUT_TO_LOCAL = 1,
87+
WALLET_OUTPUT_HTLC_OFFER = 3,
88+
WALLET_OUTPUT_HTLC_RECV = 4,
89+
WALLET_OUTPUT_OUR_CHANGE = 5,
90+
WALLET_OUTPUT_P2WPKH = 6
9191
};
9292

9393
static inline enum wallet_output_type wallet_output_type_in_db(enum wallet_output_type w)
9494
{
9595
switch (w) {
96-
case p2sh_wpkh:
97-
BUILD_ASSERT(p2sh_wpkh == 0);
96+
case WALLET_OUTPUT_P2SH_WPKH:
97+
BUILD_ASSERT(WALLET_OUTPUT_P2SH_WPKH == 0);
9898
return w;
99-
case to_local:
100-
BUILD_ASSERT(to_local == 1);
99+
case WALLET_OUTPUT_TO_LOCAL:
100+
BUILD_ASSERT(WALLET_OUTPUT_TO_LOCAL == 1);
101101
return w;
102-
case htlc_offer:
103-
BUILD_ASSERT(htlc_offer == 3);
102+
case WALLET_OUTPUT_HTLC_OFFER:
103+
BUILD_ASSERT(WALLET_OUTPUT_HTLC_OFFER == 3);
104104
return w;
105-
case htlc_recv:
106-
BUILD_ASSERT(htlc_recv == 4);
105+
case WALLET_OUTPUT_HTLC_RECV:
106+
BUILD_ASSERT(WALLET_OUTPUT_HTLC_RECV == 4);
107107
return w;
108-
case our_change:
109-
BUILD_ASSERT(our_change == 5);
108+
case WALLET_OUTPUT_OUR_CHANGE:
109+
BUILD_ASSERT(WALLET_OUTPUT_OUR_CHANGE == 5);
110110
return w;
111-
case p2wpkh:
112-
BUILD_ASSERT(p2wpkh == 6);
111+
case WALLET_OUTPUT_P2WPKH:
112+
BUILD_ASSERT(WALLET_OUTPUT_P2WPKH == 6);
113113
return w;
114114
}
115115
fatal("%s: %u is invalid", __func__, w);

0 commit comments

Comments
 (0)