@@ -497,9 +497,13 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
497
497
}
498
498
match claim {
499
499
OnchainClaim :: Tx ( tx) => {
500
- let log_start = if bumped_feerate { "Broadcasting RBF-bumped" } else { "Rebroadcasting" } ;
501
- log_info ! ( logger, "{} onchain {}" , log_start, log_tx!( tx) ) ;
502
- broadcaster. broadcast_transactions ( & [ & tx] ) ;
500
+ if tx. input . iter ( ) . any ( |input| input. witness . is_empty ( ) ) {
501
+ log_info ! ( logger, "Waiting for signature of unsigned onchain transaction {}" , tx. txid( ) ) ;
502
+ } else {
503
+ let log_start = if bumped_feerate { "Broadcasting RBF-bumped" } else { "Rebroadcasting" } ;
504
+ log_info ! ( logger, "{} onchain {}" , log_start, log_tx!( tx) ) ;
505
+ broadcaster. broadcast_transactions ( & [ & tx] ) ;
506
+ }
503
507
} ,
504
508
OnchainClaim :: Event ( event) => {
505
509
let log_start = if bumped_feerate { "Yielding fee-bumped" } else { "Replaying" } ;
@@ -636,8 +640,8 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
636
640
let commitment_tx_feerate_sat_per_1000_weight =
637
641
compute_feerate_sat_per_1000_weight ( fee_sat, tx. weight ( ) . to_wu ( ) ) ;
638
642
if commitment_tx_feerate_sat_per_1000_weight >= package_target_feerate_sat_per_1000_weight {
639
- log_debug ! ( logger, "Pre-signed {} already has feerate {} sat/kW above required {} sat/kW" ,
640
- log_tx! ( tx ) , commitment_tx_feerate_sat_per_1000_weight,
643
+ log_debug ! ( logger, "Pre-signed commitment {} already has feerate {} sat/kW above required {} sat/kW" ,
644
+ tx . txid ( ) , commitment_tx_feerate_sat_per_1000_weight,
641
645
package_target_feerate_sat_per_1000_weight) ;
642
646
return Some ( ( new_timer, 0 , OnchainClaim :: Tx ( tx. clone ( ) ) ) ) ;
643
647
}
@@ -776,8 +780,12 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
776
780
// `OnchainClaim`.
777
781
let claim_id = match claim {
778
782
OnchainClaim :: Tx ( tx) => {
779
- log_info ! ( logger, "Broadcasting onchain {}" , log_tx!( tx) ) ;
780
- broadcaster. broadcast_transactions ( & [ & tx] ) ;
783
+ if tx. input . iter ( ) . any ( |input| input. witness . is_empty ( ) ) {
784
+ log_info ! ( logger, "Waiting for signature of unsigned onchain transaction {}" , tx. txid( ) ) ;
785
+ } else {
786
+ log_info ! ( logger, "Broadcasting onchain {}" , log_tx!( tx) ) ;
787
+ broadcaster. broadcast_transactions ( & [ & tx] ) ;
788
+ }
781
789
ClaimId ( tx. txid ( ) . to_byte_array ( ) )
782
790
} ,
783
791
OnchainClaim :: Event ( claim_event) => {
@@ -969,8 +977,13 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
969
977
) {
970
978
match bump_claim {
971
979
OnchainClaim :: Tx ( bump_tx) => {
972
- log_info ! ( logger, "Broadcasting RBF-bumped onchain {}" , log_tx!( bump_tx) ) ;
973
- broadcaster. broadcast_transactions ( & [ & bump_tx] ) ;
980
+ if bump_tx. input . iter ( ) . any ( |input| input. witness . is_empty ( ) ) {
981
+ log_info ! ( logger, "Waiting for signature of RBF-bumped unsigned onchain transaction {}" ,
982
+ bump_tx. txid( ) ) ;
983
+ } else {
984
+ log_info ! ( logger, "Broadcasting RBF-bumped onchain {}" , log_tx!( bump_tx) ) ;
985
+ broadcaster. broadcast_transactions ( & [ & bump_tx] ) ;
986
+ }
974
987
} ,
975
988
OnchainClaim :: Event ( claim_event) => {
976
989
log_info ! ( logger, "Yielding RBF-bumped onchain event to spend inputs {:?}" , request. outpoints( ) ) ;
@@ -1052,8 +1065,12 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
1052
1065
request. set_feerate ( new_feerate) ;
1053
1066
match bump_claim {
1054
1067
OnchainClaim :: Tx ( bump_tx) => {
1055
- log_info ! ( logger, "Broadcasting onchain {}" , log_tx!( bump_tx) ) ;
1056
- broadcaster. broadcast_transactions ( & [ & bump_tx] ) ;
1068
+ if bump_tx. input . iter ( ) . any ( |input| input. witness . is_empty ( ) ) {
1069
+ log_info ! ( logger, "Waiting for signature of unsigned onchain transaction {}" , bump_tx. txid( ) ) ;
1070
+ } else {
1071
+ log_info ! ( logger, "Broadcasting onchain {}" , log_tx!( bump_tx) ) ;
1072
+ broadcaster. broadcast_transactions ( & [ & bump_tx] ) ;
1073
+ }
1057
1074
} ,
1058
1075
OnchainClaim :: Event ( claim_event) => {
1059
1076
log_info ! ( logger, "Yielding onchain event after reorg to spend inputs {:?}" , request. outpoints( ) ) ;
@@ -1106,13 +1123,10 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
1106
1123
& self . holder_commitment . trust ( ) . built_transaction ( ) . transaction
1107
1124
}
1108
1125
1109
- //TODO: getting lastest holder transactions should be infallible and result in us "force-closing the channel", but we may
1110
- // have empty holder commitment transaction if a ChannelMonitor is asked to force-close just after OutboundV1Channel::get_funding_created,
1111
- // before providing a initial commitment transaction. For outbound channel, init ChannelMonitor at Channel::funding_signed, there is nothing
1112
- // to monitor before.
1113
- pub ( crate ) fn get_fully_signed_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Transaction {
1114
- let sig = self . signer . sign_holder_commitment ( & self . holder_commitment , & self . secp_ctx ) . expect ( "signing holder commitment" ) ;
1115
- self . holder_commitment . add_holder_sig ( funding_redeemscript, sig)
1126
+ pub ( crate ) fn get_maybe_signed_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Transaction {
1127
+ self . signer . sign_holder_commitment ( & self . holder_commitment , & self . secp_ctx )
1128
+ . map ( |sig| self . holder_commitment . add_holder_sig ( funding_redeemscript, sig) )
1129
+ . unwrap_or_else ( |_| self . get_unsigned_holder_commitment_tx ( ) . clone ( ) )
1116
1130
}
1117
1131
1118
1132
#[ cfg( any( test, feature="unsafe_revoked_tx_signing" ) ) ]
@@ -1121,7 +1135,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
1121
1135
self . holder_commitment . add_holder_sig ( funding_redeemscript, sig)
1122
1136
}
1123
1137
1124
- pub ( crate ) fn get_fully_signed_htlc_tx ( & mut self , outp : & :: bitcoin:: OutPoint , preimage : & Option < PaymentPreimage > ) -> Option < Transaction > {
1138
+ pub ( crate ) fn get_maybe_signed_htlc_tx ( & mut self , outp : & :: bitcoin:: OutPoint , preimage : & Option < PaymentPreimage > ) -> Option < Transaction > {
1125
1139
let get_signed_htlc_tx = |holder_commitment : & HolderCommitmentTransaction | {
1126
1140
let trusted_tx = holder_commitment. trust ( ) ;
1127
1141
if trusted_tx. txid ( ) != outp. txid {
@@ -1149,10 +1163,11 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
1149
1163
preimage : preimage. clone ( ) ,
1150
1164
counterparty_sig : counterparty_htlc_sig. clone ( ) ,
1151
1165
} ;
1152
- let htlc_sig = self . signer . sign_holder_htlc_transaction ( & htlc_tx, 0 , & htlc_descriptor, & self . secp_ctx ) . unwrap ( ) ;
1153
- htlc_tx. input [ 0 ] . witness = trusted_tx. build_htlc_input_witness (
1154
- htlc_idx, & counterparty_htlc_sig, & htlc_sig, preimage,
1155
- ) ;
1166
+ if let Ok ( htlc_sig) = self . signer . sign_holder_htlc_transaction ( & htlc_tx, 0 , & htlc_descriptor, & self . secp_ctx ) {
1167
+ htlc_tx. input [ 0 ] . witness = trusted_tx. build_htlc_input_witness (
1168
+ htlc_idx, & counterparty_htlc_sig, & htlc_sig, preimage,
1169
+ ) ;
1170
+ }
1156
1171
Some ( htlc_tx)
1157
1172
} ;
1158
1173
0 commit comments