Skip to content

Commit c0ddfa2

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 7a276bb commit c0ddfa2

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
@@ -1234,7 +1234,7 @@ void fillin_missing_scriptpubkeys(struct lightningd *ld, struct db *db)
12341234
db_col_ignore(stmt, "peer_id");
12351235
db_col_ignore(stmt, "commitment_point");
12361236
bip32_pubkey(ld, &key, keyindex);
1237-
if (type == p2sh_wpkh) {
1237+
if (type == WALLET_OUTPUT_P2SH_WPKH) {
12381238
u8 *redeemscript = bitcoin_redeem_p2sh_p2wpkh(stmt, &key);
12391239
scriptPubkey = scriptpubkey_p2sh(tmpctx, redeemscript);
12401240
} else

wallet/test/run-wallet.c

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

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

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

@@ -1408,7 +1408,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
14081408
u.scriptPubkey[0] = OP_0;
14091409
u.scriptPubkey[1] = sizeof(struct sha256);
14101410
memset(u.scriptPubkey + 2, 1, sizeof(struct sha256));
1411-
CHECK_MSG(wallet_add_utxo(w, &u, our_change),
1411+
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_OUR_CHANGE),
14121412
"wallet_add_utxo with close_info");
14131413

14141414
/* Now select them */
@@ -1479,7 +1479,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
14791479
u.scriptPubkey[0] = OP_0;
14801480
u.scriptPubkey[1] = sizeof(struct ripemd160);
14811481
memset(u.scriptPubkey + 2, 1, sizeof(struct ripemd160));
1482-
CHECK_MSG(wallet_add_utxo(w, &u, p2sh_wpkh),
1482+
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2SH_WPKH),
14831483
"wallet_add_utxo with close_info no commitment_point");
14841484
CHECK_MSG(!wallet_err, wallet_err);
14851485

@@ -1561,7 +1561,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
15611561
memset(&u.outpoint, 4, sizeof(u.outpoint));
15621562
u.amount = AMOUNT_SAT(4);
15631563
u.close_info = tal_free(u.close_info);
1564-
CHECK_MSG(wallet_add_utxo(w, &u, p2wpkh),
1564+
CHECK_MSG(wallet_add_utxo(w, &u, WALLET_OUTPUT_P2WPKH),
15651565
"wallet_add_utxo failed, p2wpkh");
15661566

15671567
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
@@ -364,7 +364,7 @@ static struct utxo *wallet_stmt2output(const tal_t *ctx, struct db_stmt *stmt)
364364

365365
utxo->scriptPubkey = db_col_arr(utxo, stmt, "scriptpubkey", u8);
366366
/* FIXME: add p2tr to type? */
367-
if (db_col_int(stmt, "type") == p2sh_wpkh)
367+
if (wallet_output_type_in_db(db_col_int(stmt, "type")) == WALLET_OUTPUT_P2SH_WPKH)
368368
utxo->utxotype = UTXO_P2SH_P2WPKH;
369369
else if (is_p2wpkh(utxo->scriptPubkey, tal_bytelen(utxo->scriptPubkey), NULL))
370370
utxo->utxotype = UTXO_P2WPKH;
@@ -897,7 +897,7 @@ bool wallet_add_onchaind_utxo(struct wallet *w,
897897
db_bind_txid(stmt, &outpoint->txid);
898898
db_bind_int(stmt, outpoint->n);
899899
db_bind_amount_sat(stmt, &amount);
900-
db_bind_int(stmt, wallet_output_type_in_db(p2wpkh));
900+
db_bind_int(stmt, wallet_output_type_in_db(WALLET_OUTPUT_P2WPKH));
901901
db_bind_int(stmt, OUTPUT_STATE_AVAILABLE);
902902
db_bind_int(stmt, 0);
903903
db_bind_u64(stmt, channel->dbid);
@@ -3087,7 +3087,7 @@ static void got_utxo(struct wallet *w,
30873087
notify_chain_mvt(w->ld, mvt);
30883088
}
30893089

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

wallet/wallet.h

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

9494
static inline enum wallet_output_type wallet_output_type_in_db(enum wallet_output_type w)
9595
{
9696
switch (w) {
97-
case p2sh_wpkh:
98-
BUILD_ASSERT(p2sh_wpkh == 0);
97+
case WALLET_OUTPUT_P2SH_WPKH:
98+
BUILD_ASSERT(WALLET_OUTPUT_P2SH_WPKH == 0);
9999
return w;
100-
case to_local:
101-
BUILD_ASSERT(to_local == 1);
100+
case WALLET_OUTPUT_TO_LOCAL:
101+
BUILD_ASSERT(WALLET_OUTPUT_TO_LOCAL == 1);
102102
return w;
103-
case htlc_offer:
104-
BUILD_ASSERT(htlc_offer == 3);
103+
case WALLET_OUTPUT_HTLC_OFFER:
104+
BUILD_ASSERT(WALLET_OUTPUT_HTLC_OFFER == 3);
105105
return w;
106-
case htlc_recv:
107-
BUILD_ASSERT(htlc_recv == 4);
106+
case WALLET_OUTPUT_HTLC_RECV:
107+
BUILD_ASSERT(WALLET_OUTPUT_HTLC_RECV == 4);
108108
return w;
109-
case our_change:
110-
BUILD_ASSERT(our_change == 5);
109+
case WALLET_OUTPUT_OUR_CHANGE:
110+
BUILD_ASSERT(WALLET_OUTPUT_OUR_CHANGE == 5);
111111
return w;
112-
case p2wpkh:
113-
BUILD_ASSERT(p2wpkh == 6);
112+
case WALLET_OUTPUT_P2WPKH:
113+
BUILD_ASSERT(WALLET_OUTPUT_P2WPKH == 6);
114114
return w;
115115
}
116116
fatal("%s: %u is invalid", __func__, w);

0 commit comments

Comments
 (0)