@@ -189,6 +189,7 @@ static void update_commitment_tx_added(struct info *info, u64 htlc_id)
189189{
190190 struct changed_htlc * changed ;
191191 u8 * msg ;
192+ const struct htlc * * htlcs = tal_arr (tmpctx , const struct htlc * , 0 );
192193
193194 changed = tal_arr (tmpctx , struct changed_htlc , 1 );
194195 changed -> id = htlc_id ;
@@ -202,6 +203,8 @@ static void update_commitment_tx_added(struct info *info, u64 htlc_id)
202203 changed );
203204 daemon_conn_send (info -> dc , take (msg ));
204205
206+ channel_sending_commit (info -> channel , & htlcs );
207+
205208 /* Tell it we got revoke & ack from them. */
206209 pretend_got_revoke (info , htlc_id , RCVD_ADD_REVOCATION );
207210
@@ -220,6 +223,11 @@ static void update_commitment_tx_added(struct info *info, u64 htlc_id)
220223 NULL );
221224 daemon_conn_send (info -> dc , take (msg ));
222225
226+ /* Tell full_channel.c the htlc is totally committed. */
227+ channel_rcvd_revoke_and_ack (info -> channel , & htlcs );
228+ channel_rcvd_commit (info -> channel , & htlcs );
229+ channel_sending_revoke_and_ack (info -> channel );
230+
223231 /* Final change to SENT_ADD_ACK_REVOCATION is implied */
224232 info -> commit_num ++ ;
225233}
@@ -367,6 +375,7 @@ static void fail(struct info *info,
367375 const struct failed_htlc * * failed_arr ;
368376 u8 * msg ;
369377 struct changed_htlc * changed ;
378+ enum channel_remove_err err ;
370379
371380 msg = tal_arr (tmpctx , u8 , 0 );
372381 towire_u16 (& msg , failcode );
@@ -375,6 +384,12 @@ static void fail(struct info *info,
375384 fmt_nodeidx (tmpctx , current_nodeidx ),
376385 onion_wire_name (failcode ));
377386
387+ err = channel_fail_htlc (info -> channel ,
388+ LOCAL ,
389+ htlc -> htlc_id ,
390+ NULL );
391+ assert (err == CHANNEL_ERR_REMOVE_OK );
392+
378393 failed_arr = tal_arr (tmpctx , const struct failed_htlc * , 1 );
379394 failed_arr [0 ] = failed = tal (failed_arr , struct failed_htlc );
380395 failed -> id = htlc -> htlc_id ;
@@ -502,6 +517,15 @@ static void succeed(struct info *info,
502517 struct changed_htlc * changed ;
503518 struct fulfilled_htlc * fulfilled ;
504519 u8 * msg ;
520+ enum channel_remove_err err ;
521+
522+ err = channel_fulfill_htlc (info -> channel ,
523+ LOCAL ,
524+ htlc -> htlc_id ,
525+ preimage ,
526+ NULL );
527+ status_debug ("channel_fulfill_htlc = %i" , err );
528+ assert (err == CHANNEL_ERR_REMOVE_OK );
505529
506530 fulfilled = tal_arr (tmpctx , struct fulfilled_htlc , 1 );
507531 fulfilled -> id = htlc -> htlc_id ;
@@ -836,7 +860,6 @@ static void handle_offer_htlc(struct info *info, const u8 *inmsg)
836860 u8 * msg ;
837861 u32 cltv_expiry ;
838862 struct amount_msat amount ;
839- struct sha256 payment_hash ;
840863 u8 onion_routing_packet [TOTAL_PACKET_SIZE (ROUTING_INFO_SIZE )];
841864 enum channel_add_err e ;
842865 const u8 * failwiremsg ;
@@ -854,7 +877,7 @@ static void handle_offer_htlc(struct info *info, const u8 *inmsg)
854877 master_badmsg (WIRE_CHANNELD_OFFER_HTLC , inmsg );
855878
856879 e = channel_add_htlc (info -> channel , LOCAL , htlc -> htlc_id ,
857- amount , cltv_expiry , & payment_hash ,
880+ amount , cltv_expiry , & htlc -> payment_hash ,
858881 onion_routing_packet , take (blinding ), NULL ,
859882 & htlc_fee , true);
860883 status_debug ("Adding HTLC %" PRIu64 " amount=%s cltv=%u gave %s" ,
0 commit comments