From cc986392e2b17a7cd50fa7cb703cc33e43b733dd Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 13 Sep 2016 19:38:03 +1000 Subject: [PATCH] ckdb - payaddress updates have a non-fixed field name so are not intransient --- src/ckdb.h | 2 +- src/ckdb_cmd.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index cd0895b7..43db26f2 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -58,7 +58,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.501" +#define CKDB_VERSION DB_VERSION"-2.502" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 4a7f4ec4..05b54397 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -471,12 +471,12 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id, __maybe_unused tv_t *notcd, K_TREE *trf_root, __maybe_unused bool reload_data) { - INTRANSIENT *in_username, *in_address; - K_ITEM *i_passwordhash, *i_2fa, *i_rows; + INTRANSIENT *in_username; + K_ITEM *i_passwordhash, *i_2fa, *i_rows, *i_address; K_ITEM *i_ratio, *i_payname, *i_email, *u_item, *pa_item, *old_pa_item; K_ITEM *ua_item = NULL; USERATTS *useratts = NULL; - char *email, *payname; + char *email, *address, *payname; char reply[1024] = ""; size_t siz = sizeof(reply); int event = EVENT_OK; @@ -650,22 +650,24 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id, if (ratio == 0) continue; + // This name won't be intransient snprintf(tmp, sizeof(tmp), "address:%d", i); - in_address = require_in(trf_root, tmp, - ADDR_MIN_LEN, - (char *)addrpatt, - reply, siz); - if (!in_address) { + i_address = require_name(trf_root, tmp, + ADDR_MIN_LEN, + (char *)addrpatt, + reply, siz); + if (!i_address) { K_WUNLOCK(paymentaddresses_free); event = events_add(EVENTID_INCBTC, trf_root); reason = "Invalid address"; goto struckout; } + address = transfer_data(i_address); pa_item = STORE_HEAD_NOLOCK(pa_store); while (pa_item) { DATA_PAYMENTADDRESSES(row, pa_item); - if (INTREQ(row->in_payaddress, in_address->str)) { + if (strcmp(row->in_payaddress, address) == 0) { K_WUNLOCK(paymentaddresses_free); reason = "Duplicate address"; goto struckout; @@ -683,7 +685,7 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id, pa_item = k_unlink_head(paymentaddresses_free); DATA_PAYMENTADDRESSES(row, pa_item); bzero(row, sizeof(*row)); - row->in_payaddress = in_address->str; + row->in_payaddress = intransient_str("payaddress", address); row->payratio = ratio; STRNCPY(row->payname, payname); k_add_head(pa_store, pa_item);