Skip to content

Commit

Permalink
wallet: rename enum wallet_payment_status to payment_status.
Browse files Browse the repository at this point in the history
We use it everywhere, the wallet_ prefix is weird.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jul 18, 2023
1 parent 19669d8 commit c7026e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct sendpay_command {
};

static bool string_to_payment_status(const char *status_str, size_t len,
enum wallet_payment_status *status)
enum payment_status *status)
{
if (memeqstr(status_str, len, "complete")) {
*status = PAYMENT_COMPLETE;
Expand All @@ -52,7 +52,7 @@ static bool string_to_payment_status(const char *status_str, size_t len,
return false;
}

static const char *payment_status_to_string(const enum wallet_payment_status status)
static const char *payment_status_to_string(const enum payment_status status)
{
switch (status) {
case PAYMENT_COMPLETE:
Expand Down Expand Up @@ -1534,9 +1534,9 @@ static struct command_result *param_payment_status(struct command *cmd,
const char *name,
const char *buffer,
const jsmntok_t *tok,
enum wallet_payment_status **status)
enum payment_status **status)
{
*status = tal(cmd, enum wallet_payment_status);
*status = tal(cmd, enum payment_status);
if (string_to_payment_status(buffer + tok->start,
tok->end - tok->start,
*status))
Expand All @@ -1555,7 +1555,7 @@ static struct command_result *json_listsendpays(struct command *cmd,
struct json_stream *response;
struct sha256 *rhash;
const char *invstring;
enum wallet_payment_status *status;
enum payment_status *status;

if (!param(cmd, buffer, params,
/* FIXME: parameter should be invstring now */
Expand Down Expand Up @@ -1622,7 +1622,7 @@ param_payment_status_nopending(struct command *cmd,
const char *name,
const char *buffer,
const jsmntok_t *tok,
enum wallet_payment_status **status)
enum payment_status **status)
{
struct command_result *res;

Expand All @@ -1646,10 +1646,10 @@ static struct command_result *json_delpay(struct command *cmd,
const jsmntok_t *obj UNNEEDED,
const jsmntok_t *params)
{
const enum wallet_payment_status *found_status = NULL;
const enum payment_status *found_status = NULL;
struct json_stream *response;
const struct wallet_payment **payments;
enum wallet_payment_status *status;
enum payment_status *status;
struct sha256 *payment_hash;
u64 *groupid, *partid;
bool found;
Expand Down
6 changes: 3 additions & 3 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3352,7 +3352,7 @@ u64 wallet_payment_get_groupid(struct wallet *wallet,
void wallet_payment_delete(struct wallet *wallet,
const struct sha256 *payment_hash,
const u64 *groupid, const u64 *partid,
const enum wallet_payment_status *status)
const enum payment_status *status)
{
struct db_stmt *stmt;

Expand Down Expand Up @@ -3516,7 +3516,7 @@ wallet_payment_by_hash(const tal_t *ctx, struct wallet *wallet,
void wallet_payment_set_status(struct wallet *wallet,
const struct sha256 *payment_hash,
u64 partid, u64 groupid,
const enum wallet_payment_status newstatus,
const enum payment_status newstatus,
const struct preimage *preimage)
{
struct db_stmt *stmt;
Expand All @@ -3538,7 +3538,7 @@ void wallet_payment_set_status(struct wallet *wallet,
SQL("UPDATE payments SET status=?, completed_at=? "
"WHERE payment_hash=? AND partid=? AND groupid=?"));

db_bind_int(stmt, 0, wallet_payment_status_in_db(newstatus));
db_bind_int(stmt, 0, payment_status_in_db(newstatus));
if (completed_at != 0) {
db_bind_u64(stmt, 1, completed_at);
} else {
Expand Down
14 changes: 7 additions & 7 deletions wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ struct wallet_shachain {
struct shachain chain;
};

/* Possible states for a wallet_payment. Payments start in
/* Possible states for a payment. Payments start in
* `PENDING`. Outgoing payments are set to `PAYMENT_COMPLETE` once we
* get the preimage matching the rhash, or to
* `PAYMENT_FAILED`. */
/* /!\ This is a DB ENUM, please do not change the numbering of any
* already defined elements (adding is ok but you should append the
* test case test_wallet_payment_status_enum() ) /!\ */
enum wallet_payment_status {
* test case test_payment_status_enum() ) /!\ */
enum payment_status {
PAYMENT_PENDING = 0,
PAYMENT_COMPLETE = 1,
PAYMENT_FAILED = 2
Expand All @@ -310,7 +310,7 @@ struct tx_annotation {
struct short_channel_id channel;
};

static inline enum wallet_payment_status wallet_payment_status_in_db(enum wallet_payment_status w)
static inline enum payment_status payment_status_in_db(enum payment_status w)
{
switch (w) {
case PAYMENT_PENDING:
Expand Down Expand Up @@ -342,7 +342,7 @@ struct wallet_payment {
u64 partid;
u64 groupid;

enum wallet_payment_status status;
enum payment_status status;

/* The destination may not be known if we used `sendonion` */
struct node_id *destination;
Expand Down Expand Up @@ -1115,7 +1115,7 @@ void wallet_payment_store(struct wallet *wallet,
void wallet_payment_delete(struct wallet *wallet,
const struct sha256 *payment_hash,
const u64 *groupid, const u64 *partid,
const enum wallet_payment_status *status);
const enum payment_status *status);

/**
* wallet_local_htlc_out_delete - Remove a local outgoing failed HTLC
Expand Down Expand Up @@ -1157,7 +1157,7 @@ u64 wallet_payment_get_groupid(struct wallet *wallet,
void wallet_payment_set_status(struct wallet *wallet,
const struct sha256 *payment_hash,
u64 partid, u64 groupid,
const enum wallet_payment_status newstatus,
const enum payment_status newstatus,
const struct preimage *preimage);

/**
Expand Down

0 comments on commit c7026e5

Please sign in to comment.