@@ -681,6 +681,44 @@ static bool channel_announcement_negotiate(struct peer *peer)
681
681
return sent_announcement ;
682
682
}
683
683
684
+ static void lock_signer_outpoint (const struct bitcoin_outpoint * outpoint ) {
685
+ const u8 * msg ;
686
+ bool is_buried = false;
687
+
688
+ do {
689
+ /* Make sure the hsmd agrees that this outpoint is
690
+ * sufficiently buried. */
691
+ msg = towire_hsmd_check_outpoint (NULL , & outpoint -> txid , outpoint -> n );
692
+ msg = hsm_req (tmpctx , take (msg ));
693
+ if (!fromwire_hsmd_check_outpoint_reply (msg , & is_buried ))
694
+ status_failed (STATUS_FAIL_HSM_IO ,
695
+ "Bad hsmd_check_outpoint_reply: %s" ,
696
+ tal_hex (tmpctx , msg ));
697
+
698
+ /* the signer should have a shorter buried height requirement so
699
+ * it almost always will be ready ahead of us.*/
700
+ if (!is_buried ) {
701
+ sleep (10 );
702
+ }
703
+ } while (!is_buried );
704
+
705
+ /* tell the signer that we are now locked */
706
+ msg = towire_hsmd_lock_outpoint (NULL , & outpoint -> txid , outpoint -> n );
707
+ msg = hsm_req (tmpctx , take (msg ));
708
+ if (!fromwire_hsmd_lock_outpoint_reply (msg ))
709
+ status_failed (STATUS_FAIL_HSM_IO ,
710
+ "Bad hsmd_lock_outpoint_reply: %s" ,
711
+ tal_hex (tmpctx , msg ));
712
+ }
713
+
714
+ /* Call this method when channel_ready status are changed. */
715
+ static void check_mutual_channel_ready (const struct peer * peer )
716
+ {
717
+ if (peer -> channel_ready [LOCAL ] && peer -> channel_ready [REMOTE ]) {
718
+ lock_signer_outpoint (& peer -> channel -> funding );
719
+ }
720
+ }
721
+
684
722
/* Call this method when splice_locked status are changed. If both sides have
685
723
* splice_locked'ed than this function consumes the `splice_locked_ready` values
686
724
* and considers the channel funding to be switched to the splice tx. */
@@ -831,6 +869,7 @@ static void handle_peer_channel_ready(struct peer *peer, const u8 *msg)
831
869
832
870
peer -> tx_sigs_allowed = false;
833
871
peer -> channel_ready [REMOTE ] = true;
872
+ check_mutual_channel_ready (peer );
834
873
if (tlvs -> short_channel_id != NULL ) {
835
874
status_debug (
836
875
"Peer told us that they'll use alias=%s for this channel" ,
@@ -5228,6 +5267,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
5228
5267
peer_write (peer -> pps , take (msg ));
5229
5268
5230
5269
peer -> channel_ready [LOCAL ] = true;
5270
+ check_mutual_channel_ready (peer );
5231
5271
}
5232
5272
else if (splicing && !peer -> splice_state -> locked_ready [LOCAL ]) {
5233
5273
assert (scid );
0 commit comments