mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +01:00
channeld: use wirestring for failure strings.
I think this code predated wirestring. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -88,8 +88,7 @@ msgtype,channel_offer_htlc_reply,1104
|
||||
msgdata,channel_offer_htlc_reply,id,u64,
|
||||
# Zero failure code means success.,
|
||||
msgdata,channel_offer_htlc_reply,failure_code,u16,
|
||||
msgdata,channel_offer_htlc_reply,failurestrlen,u16,
|
||||
msgdata,channel_offer_htlc_reply,failurestr,u8,failurestrlen
|
||||
msgdata,channel_offer_htlc_reply,failurestr,wirestring,
|
||||
|
||||
# Main daemon found out the preimage for an HTLC
|
||||
#include <bitcoin/preimage.h>
|
||||
|
||||
|
@@ -2608,8 +2608,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
|
||||
u8 onion_routing_packet[TOTAL_PACKET_SIZE];
|
||||
enum channel_add_err e;
|
||||
enum onion_type failcode;
|
||||
/* Subtle: must be tal object since we marshal using tal_bytelen() */
|
||||
const char *failmsg;
|
||||
const char *failstr;
|
||||
struct amount_sat htlc_fee;
|
||||
|
||||
if (!peer->funding_locked[LOCAL] || !peer->funding_locked[REMOTE])
|
||||
@@ -2641,13 +2640,13 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
|
||||
start_commit_timer(peer);
|
||||
/* Tell the master. */
|
||||
msg = towire_channel_offer_htlc_reply(NULL, peer->htlc_id,
|
||||
0, NULL);
|
||||
0, "");
|
||||
wire_sync_write(MASTER_FD, take(msg));
|
||||
peer->htlc_id++;
|
||||
return;
|
||||
case CHANNEL_ERR_INVALID_EXPIRY:
|
||||
failcode = WIRE_INCORRECT_CLTV_EXPIRY;
|
||||
failmsg = tal_fmt(inmsg, "Invalid cltv_expiry %u", cltv_expiry);
|
||||
failstr = tal_fmt(inmsg, "Invalid cltv_expiry %u", cltv_expiry);
|
||||
goto failed;
|
||||
case CHANNEL_ERR_DUPLICATE:
|
||||
case CHANNEL_ERR_DUPLICATE_ID_DIFFERENT:
|
||||
@@ -2656,30 +2655,30 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
|
||||
|
||||
case CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED:
|
||||
failcode = WIRE_REQUIRED_CHANNEL_FEATURE_MISSING;
|
||||
failmsg = tal_fmt(inmsg, "Mini mode: maximum value exceeded");
|
||||
failstr = "Mini mode: maximum value exceeded";
|
||||
goto failed;
|
||||
/* FIXME: Fuzz the boundaries a bit to avoid probing? */
|
||||
case CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED:
|
||||
failcode = WIRE_TEMPORARY_CHANNEL_FAILURE;
|
||||
failmsg = tal_fmt(inmsg, "Capacity exceeded - HTLC fee: %s", fmt_amount_sat(inmsg, &htlc_fee));
|
||||
failstr = tal_fmt(inmsg, "Capacity exceeded - HTLC fee: %s", fmt_amount_sat(inmsg, &htlc_fee));
|
||||
goto failed;
|
||||
case CHANNEL_ERR_HTLC_BELOW_MINIMUM:
|
||||
failcode = WIRE_AMOUNT_BELOW_MINIMUM;
|
||||
failmsg = tal_fmt(inmsg, "HTLC too small (%s minimum)",
|
||||
failstr = tal_fmt(inmsg, "HTLC too small (%s minimum)",
|
||||
type_to_string(tmpctx,
|
||||
struct amount_msat,
|
||||
&peer->channel->config[REMOTE].htlc_minimum));
|
||||
goto failed;
|
||||
case CHANNEL_ERR_TOO_MANY_HTLCS:
|
||||
failcode = WIRE_TEMPORARY_CHANNEL_FAILURE;
|
||||
failmsg = tal_fmt(inmsg, "Too many HTLCs");
|
||||
failstr = "Too many HTLCs";
|
||||
goto failed;
|
||||
}
|
||||
/* Shouldn't return anything else! */
|
||||
abort();
|
||||
|
||||
failed:
|
||||
msg = towire_channel_offer_htlc_reply(NULL, 0, failcode, (u8*)failmsg);
|
||||
msg = towire_channel_offer_htlc_reply(NULL, 0, failcode, failstr);
|
||||
wire_sync_write(MASTER_FD, take(msg));
|
||||
}
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNU
|
||||
struct htlc_out *hout)
|
||||
{
|
||||
u16 failure_code;
|
||||
u8 *failurestr;
|
||||
char *failurestr;
|
||||
struct lightningd *ld = subd->ld;
|
||||
|
||||
if (!fromwire_channel_offer_htlc_reply(msg, msg,
|
||||
@@ -380,10 +380,9 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNU
|
||||
if (failure_code) {
|
||||
hout->failcode = (enum onion_type) failure_code;
|
||||
if (hout->am_origin) {
|
||||
char *localfail = tal_fmt(msg, "%s: %.*s",
|
||||
char *localfail = tal_fmt(msg, "%s: %s",
|
||||
onion_type_name(failure_code),
|
||||
(int)tal_count(failurestr),
|
||||
(const char *)failurestr);
|
||||
failurestr);
|
||||
payment_failed(ld, hout, localfail);
|
||||
|
||||
} else if (hout->in) {
|
||||
|
||||
@@ -103,7 +103,7 @@ bool fromwire_channel_got_commitsig(const tal_t *ctx UNNEEDED, const void *p UNN
|
||||
bool fromwire_channel_got_revoke(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *revokenum UNNEEDED, struct secret *per_commitment_secret UNNEEDED, struct pubkey *next_per_commit_point UNNEEDED, struct fee_states **fee_states UNNEEDED, struct changed_htlc **changed UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_got_revoke called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_channel_offer_htlc_reply */
|
||||
bool fromwire_channel_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *id UNNEEDED, u16 *failure_code UNNEEDED, u8 **failurestr UNNEEDED)
|
||||
bool fromwire_channel_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *id UNNEEDED, u16 *failure_code UNNEEDED, wirestring **failurestr UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_offer_htlc_reply called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_channel_sending_commitsig */
|
||||
bool fromwire_channel_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct fee_states **fee_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, secp256k1_ecdsa_signature **htlc_sigs UNNEEDED)
|
||||
|
||||
Reference in New Issue
Block a user