Skip to content

Commit 3ae8c4a

Browse files
committed
Fetch HolderCommitmentPoint::current_point on read
When reading HolderCommitmentPoint, attempt to fetch the current point if it wasn't serialized. This allows channels to be spliced without first needing to have the HolderCommitmentPoint advanced. Don't fail if it can't be fetch synchronously as the channel can still be spliced once it is advanced.
1 parent 7a5a2a9 commit 3ae8c4a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13837,11 +13837,26 @@ where
1383713837
// If we're restoring this channel for the first time after an upgrade, then we require that the
1383813838
// signer be available so that we can immediately populate the next commitment point. Channel
1383913839
// restoration will fail if this is not possible.
13840-
let holder_commitment_point =
13840+
let holder_commitment_point = {
13841+
let current_point = holder_commitment_point_current_opt.or_else(|| {
13842+
if holder_commitment_next_transaction_number == INITIAL_COMMITMENT_NUMBER {
13843+
None
13844+
} else {
13845+
// If the current point is not available then splicing can't be initiated
13846+
// until the next point is advanced and becomes the current point.
13847+
holder_signer
13848+
.get_per_commitment_point(
13849+
holder_commitment_next_transaction_number + 1,
13850+
&secp_ctx,
13851+
)
13852+
.ok()
13853+
}
13854+
});
13855+
1384113856
match (holder_commitment_point_next_opt, holder_commitment_point_pending_next_opt) {
1384213857
(Some(next_point), pending_next_point) => HolderCommitmentPoint {
1384313858
next_transaction_number: holder_commitment_next_transaction_number,
13844-
current_point: holder_commitment_point_current_opt,
13859+
current_point,
1384513860
next_point,
1384613861
pending_next_point,
1384713862
},
@@ -13861,12 +13876,13 @@ where
1386113876
);
1386213877
HolderCommitmentPoint {
1386313878
next_transaction_number: holder_commitment_next_transaction_number,
13864-
current_point: holder_commitment_point_current_opt,
13879+
current_point,
1386513880
next_point,
1386613881
pending_next_point: Some(pending_next_point),
1386713882
}
1386813883
},
13869-
};
13884+
}
13885+
};
1387013886

1387113887
Ok(FundedChannel {
1387213888
funding: FundingScope {

0 commit comments

Comments
 (0)