@@ -606,6 +606,18 @@ static void sign_our_inputs(struct hsm_utxo **utxos, struct wally_psbt *psbt)
606606 }
607607}
608608
609+ static void check_overgrind (const struct bitcoin_signature * sig )
610+ {
611+ u8 der [73 ];
612+ size_t len ;
613+
614+ if (!dev_warn_on_overgrind )
615+ return ;
616+ len = signature_to_der (der , sig );
617+ if (len != 71 )
618+ hsmd_status_broken ("overgrind: short signature length %zu" , len );
619+ }
620+
609621/*~ This covers several cases where onchaind is creating a transaction which
610622 * sends funds to our internal wallet. */
611623/* FIXME: Derive output address for this client, and check it here! */
@@ -632,6 +644,7 @@ static u8 *handle_sign_to_us_tx(struct hsmd_client *c, const u8 *msg_in,
632644 return hsmd_status_bad_request (c , msg_in , "bad txinput count" );
633645
634646 sign_tx_input (tx , 0 , NULL , wscript , privkey , & pubkey , sighash_type , & sig );
647+ check_overgrind (& sig );
635648
636649 return towire_hsmd_sign_tx_reply (NULL , & sig );
637650}
@@ -1401,6 +1414,7 @@ static u8 *handle_sign_mutual_close_tx(struct hsmd_client *c, const u8 *msg_in)
14011414 & secrets .funding_privkey ,
14021415 & local_funding_pubkey ,
14031416 SIGHASH_ALL , & sig );
1417+ check_overgrind (& sig );
14041418
14051419 return towire_hsmd_sign_tx_reply (NULL , & sig );
14061420}
@@ -1435,6 +1449,7 @@ static u8 *handle_sign_splice_tx(struct hsmd_client *c, const u8 *msg_in)
14351449 & secrets .funding_privkey ,
14361450 & local_funding_pubkey ,
14371451 SIGHASH_ALL , & sig );
1452+ check_overgrind (& sig );
14381453
14391454 return towire_hsmd_sign_tx_reply (NULL , & sig );
14401455}
@@ -1513,6 +1528,7 @@ static u8 *do_sign_local_htlc_tx(struct hsmd_client *c,
15131528 ? (SIGHASH_SINGLE |SIGHASH_ANYONECANPAY )
15141529 : SIGHASH_ALL ,
15151530 & sig );
1531+ check_overgrind (& sig );
15161532
15171533 return towire_hsmd_sign_tx_reply (NULL , & sig );
15181534}
@@ -1605,6 +1621,7 @@ static u8 *handle_sign_remote_htlc_tx(struct hsmd_client *c, const u8 *msg_in)
16051621 option_anchor_outputs
16061622 ? (SIGHASH_SINGLE |SIGHASH_ANYONECANPAY )
16071623 : SIGHASH_ALL , & sig );
1624+ check_overgrind (& sig );
16081625
16091626 return towire_hsmd_sign_tx_reply (NULL , & sig );
16101627}
@@ -1662,6 +1679,7 @@ static u8 *handle_sign_remote_commitment_tx(struct hsmd_client *c, const u8 *msg
16621679 & local_funding_pubkey ,
16631680 SIGHASH_ALL ,
16641681 & sig );
1682+ check_overgrind (& sig );
16651683
16661684 return towire_hsmd_sign_tx_reply (NULL , & sig );
16671685}
@@ -1855,6 +1873,7 @@ static u8 *handle_sign_commitment_tx(struct hsmd_client *c, const u8 *msg_in)
18551873 & local_funding_pubkey ,
18561874 SIGHASH_ALL ,
18571875 & sig );
1876+ check_overgrind (& sig );
18581877
18591878 return towire_hsmd_sign_commitment_tx_reply (NULL , & sig );
18601879}
0 commit comments