diff --git a/lightningd/pay.c b/lightningd/pay.c index e4e9f3290..5d5b4aec2 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -108,6 +108,10 @@ void json_add_payment_fields(struct json_stream *response, json_add_string(response, "label", t->label); if (t->bolt11) json_add_string(response, "bolt11", t->bolt11); + + if (t->failonion) + json_add_hex(response, "erroronion", t->failonion, + tal_count(t->failonion)); } static struct command_result *sendpay_success(struct command *cmd, @@ -855,6 +859,7 @@ send_payment(struct lightningd *ld, payment->path_secrets = tal_steal(payment, path_secrets); payment->route_nodes = tal_steal(payment, ids); payment->route_channels = tal_steal(payment, channels); + payment->failonion = NULL; if (label != NULL) payment->label = tal_strdup(payment, label); else @@ -1034,6 +1039,7 @@ static struct command_result *json_sendonion(struct command *cmd, payment->route_nodes = NULL; payment->route_channels = NULL; payment->bolt11 = NULL; + payment->failonion = NULL; payment->path_secrets = tal_steal(payment, path_secrets); if (label != NULL) diff --git a/tests/test_pay.py b/tests/test_pay.py index ab24b0cfc..8e8b183bc 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2559,5 +2559,5 @@ def test_sendonion_rpc(node_factory): try: l1.rpc.waitsendpay(payment_hash=payment_hash) except RpcError as e: - assert(e.error['code'] == 202) - assert(e.error['message'] == "Malformed error reply") + assert(e.error['code'] == 204) + assert(e.error['data']['raw_message'] == "400f00000000000003e80000006c") diff --git a/wallet/wallet.c b/wallet/wallet.c index b9022725b..27a31fe18 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -2244,6 +2244,13 @@ static struct wallet_payment *wallet_stmt2payment(const tal_t *ctx, else payment->bolt11 = NULL; + if (!db_column_is_null(stmt, 13)) + payment->failonion = + tal_dup_arr(payment, u8, db_column_blob(stmt, 13), + db_column_bytes(stmt, 13), 0); + else + payment->failonion = NULL; + return payment; } @@ -2273,6 +2280,7 @@ wallet_payment_by_hash(const tal_t *ctx, struct wallet *wallet, ", msatoshi_sent" ", description" ", bolt11" + ", failonionreply" " FROM payments" " WHERE payment_hash = ?")); @@ -2492,6 +2500,7 @@ wallet_payment_list(const tal_t *ctx, ", msatoshi_sent" ", description" ", bolt11" + ", failonionreply" " FROM payments" " WHERE payment_hash = ?;")); db_bind_sha256(stmt, 0, payment_hash); @@ -2510,6 +2519,7 @@ wallet_payment_list(const tal_t *ctx, ", msatoshi_sent" ", description" ", bolt11" + ", failonionreply" " FROM payments;")); } db_query_prepared(stmt); diff --git a/wallet/wallet.h b/wallet/wallet.h index c8a51e937..66a1f0e8f 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -267,6 +267,9 @@ struct wallet_payment { /* The label of the payment. Must support `tal_len` */ const char *label; + + /* If we could not decode the fail onion, just add it here. */ + const u8 *failonion; }; struct outpoint {