Skip to content

Commit cdd80e5

Browse files
committed
Use PackageId rather than Txid in OnchainEvent::Claim
In 19daccf, a `PackageId` type was added to differentiate between an opaque Id for packages and the `Txid` type which was being used for that purpose. It, however, failed to also replace the single inner field in `OnchainEvent::Claim` which was also a package ID. We do so here.
1 parent eea56e9 commit cdd80e5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lightning/src/chain/onchaintx.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ enum OnchainEvent {
7979
/// Outpoint under claim process by our own tx, once this one get enough confirmations, we remove it from
8080
/// bump-txn candidate buffer.
8181
Claim {
82-
claim_request: Txid,
82+
package_id: PackageID,
8383
},
8484
/// Claim tx aggregate multiple claimable outpoints. One of the outpoint may be claimed by a counterparty party tx.
8585
/// In this case, we need to drop the outpoint and regenerate a new claim tx. By safety, we keep tracking
@@ -123,7 +123,7 @@ impl MaybeReadable for OnchainEventEntry {
123123

124124
impl_writeable_tlv_based_enum_upgradable!(OnchainEvent,
125125
(0, Claim) => {
126-
(0, claim_request, required),
126+
(0, package_id, required),
127127
},
128128
(1, ContentiousOutpoint) => {
129129
(0, package, required),
@@ -480,8 +480,8 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
480480
// We check for outpoint spends within claims individually rather than as a set
481481
// since requests can have outpoints split off.
482482
if !self.onchain_events_awaiting_threshold_conf.iter()
483-
.any(|event_entry| if let OnchainEvent::Claim { claim_request } = event_entry.event {
484-
first_claim_txid_height.0 == claim_request.into_inner()
483+
.any(|event_entry| if let OnchainEvent::Claim { package_id } = event_entry.event {
484+
first_claim_txid_height.0 == package_id
485485
} else {
486486
// The onchain event is not a claim, keep seeking until we find one.
487487
false
@@ -766,7 +766,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
766766
txid: tx.txid(),
767767
height: conf_height,
768768
block_hash: Some(conf_hash),
769-
event: OnchainEvent::Claim { claim_request: Txid::from_inner(first_claim_txid_height.0) }
769+
event: OnchainEvent::Claim { package_id: first_claim_txid_height.0 }
770770
};
771771
if !self.onchain_events_awaiting_threshold_conf.contains(&entry) {
772772
self.onchain_events_awaiting_threshold_conf.push(entry);
@@ -821,13 +821,13 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
821821
for entry in onchain_events_awaiting_threshold_conf {
822822
if entry.has_reached_confirmation_threshold(cur_height) {
823823
match entry.event {
824-
OnchainEvent::Claim { claim_request } => {
825-
let package_id = claim_request.into_inner();
824+
OnchainEvent::Claim { package_id } => {
826825
// We may remove a whole set of claim outpoints here, as these one may have
827826
// been aggregated in a single tx and claimed so atomically
828827
if let Some(request) = self.pending_claim_requests.remove(&package_id) {
829828
for outpoint in request.outpoints() {
830-
log_debug!(logger, "Removing claim tracking for {} due to maturation of claim tx {}.", outpoint, claim_request);
829+
log_debug!(logger, "Removing claim tracking for {} due to maturation of claim tx {}.",
830+
outpoint, log_bytes!(package_id));
831831
self.claimable_outpoints.remove(&outpoint);
832832
#[cfg(anchors)]
833833
self.pending_claim_events.remove(&package_id);

0 commit comments

Comments
 (0)