waitsendpay: indicate which channel direction the error was.

You can figure this yourself by knowing the route, but it's better to report
it directly here.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-01-15 14:32:27 +10:30
committed by Christian Decker
parent c0cfddfa95
commit be64dd84ca
8 changed files with 59 additions and 19 deletions

View File

@@ -354,6 +354,8 @@ char *dbmigrations[] = {
", state INTEGER"
", UNIQUE(in_htlc_id, out_htlc_id)"
");",
/* Add a direction for failed payments. */
"ALTER TABLE payments ADD faildirection INTEGER;", /* erring_direction */
NULL,
};

View File

@@ -1838,7 +1838,8 @@ void wallet_payment_get_failinfo(const tal_t *ctx,
struct pubkey **failnode,
struct short_channel_id **failchannel,
u8 **failupdate,
char **faildetail)
char **faildetail,
int *faildirection)
{
sqlite3_stmt *stmt;
int res;
@@ -1849,7 +1850,7 @@ void wallet_payment_get_failinfo(const tal_t *ctx,
"SELECT failonionreply, faildestperm"
" , failindex, failcode"
" , failnode, failchannel"
" , failupdate, faildetail"
" , failupdate, faildetail, faildirection"
" FROM payments"
" WHERE payment_hash=?;");
sqlite3_bind_sha256(stmt, 1, payment_hash);
@@ -1878,6 +1879,9 @@ void wallet_payment_get_failinfo(const tal_t *ctx,
*failchannel = tal(ctx, struct short_channel_id);
resb = sqlite3_column_short_channel_id(stmt, 5, *failchannel);
assert(resb);
/* For pre-0.6.2 dbs, direction will be 0 */
*faildirection = sqlite3_column_int(stmt, 8);
}
if (sqlite3_column_type(stmt, 6) == SQLITE_NULL)
*failupdate = NULL;
@@ -1901,7 +1905,8 @@ void wallet_payment_set_failinfo(struct wallet *wallet,
const struct pubkey *failnode,
const struct short_channel_id *failchannel,
const u8 *failupdate /*tal_arr*/,
const char *faildetail)
const char *faildetail,
int faildirection)
{
sqlite3_stmt *stmt;
@@ -1915,6 +1920,7 @@ void wallet_payment_set_failinfo(struct wallet *wallet,
" , failchannel=?"
" , failupdate=?"
" , faildetail=?"
" , faildirection=?"
" WHERE payment_hash=?;");
if (failonionreply)
sqlite3_bind_blob(stmt, 1,
@@ -1935,8 +1941,11 @@ void wallet_payment_set_failinfo(struct wallet *wallet,
struct short_channel_id *scid = tal(tmpctx, struct short_channel_id);
*scid = *failchannel;
sqlite3_bind_short_channel_id(stmt, 6, scid);
} else
sqlite3_bind_int(stmt, 9, faildirection);
} else {
sqlite3_bind_null(stmt, 6);
sqlite3_bind_null(stmt, 9);
}
if (failupdate)
sqlite3_bind_blob(stmt, 7,
failupdate, tal_count(failupdate),
@@ -1947,7 +1956,7 @@ void wallet_payment_set_failinfo(struct wallet *wallet,
faildetail, strlen(faildetail),
SQLITE_TRANSIENT);
sqlite3_bind_sha256(stmt, 9, payment_hash);
sqlite3_bind_sha256(stmt, 10, payment_hash);
db_exec_prepared(wallet->db, stmt);
}

View File

@@ -883,7 +883,8 @@ void wallet_payment_set_status(struct wallet *wallet,
* wallet_payment_get_failinfo - Get failure information for a given
* `payment_hash`.
*
* Data is allocated as children of the given context.
* Data is allocated as children of the given context. *faildirection
* is only set if *failchannel is set non-NULL.
*/
void wallet_payment_get_failinfo(const tal_t *ctx,
struct wallet *wallet,
@@ -896,7 +897,8 @@ void wallet_payment_get_failinfo(const tal_t *ctx,
struct pubkey **failnode,
struct short_channel_id **failchannel,
u8 **failupdate,
char **faildetail);
char **faildetail,
int *faildirection);
/**
* wallet_payment_set_failinfo - Set failure information for a given
* `payment_hash`.
@@ -910,7 +912,8 @@ void wallet_payment_set_failinfo(struct wallet *wallet,
const struct pubkey *failnode,
const struct short_channel_id *failchannel,
const u8 *failupdate,
const char *faildetail);
const char *faildetail,
int faildirection);
/**
* wallet_payment_list - Retrieve a list of payments