@@ -343,6 +343,13 @@ send_payment_req(struct command *aux_cmd,
343343
344344/* For self-pay, we don't have hops. */
345345static struct amount_msat initial_sent (const struct attempt * attempt )
346+ {
347+ if (tal_count (attempt -> hops ) == 0 )
348+ return attempt -> delivers ;
349+ return attempt -> hops [0 ].amount_out ;
350+ }
351+
352+ static struct amount_msat inject_amount (const struct attempt * attempt )
346353{
347354 if (tal_count (attempt -> hops ) == 0 )
348355 return attempt -> delivers ;
@@ -1143,7 +1150,7 @@ static struct command_result *do_inject(struct command *aux_cmd,
11431150 json_add_hex_talarr (req -> js , "onion" , onion );
11441151 json_add_sha256 (req -> js , "payment_hash" , & attempt -> payment -> payment_hash );
11451152 /* If no route, its the same as delivery (self-pay) */
1146- json_add_amount_msat (req -> js , "amount_msat" , initial_sent (attempt ));
1153+ json_add_amount_msat (req -> js , "amount_msat" , inject_amount (attempt ));
11471154 json_add_u32 (req -> js , "cltv_expiry" , initial_cltv_delta (attempt ) + effective_bheight );
11481155 json_add_u64 (req -> js , "partid" , attempt -> partid );
11491156 json_add_u64 (req -> js , "groupid" , attempt -> payment -> group_id );
0 commit comments