Skip to content

Commit

Permalink
Trigger PaymentWaitingConfirmation event when MRH payment is unconfirmed
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed Nov 20, 2024
1 parent 161e8ff commit a073084
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions lib/core/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,25 +450,42 @@ impl LiquidSdk {
Pending => {
match &payment.details.get_swap_id() {
Some(swap_id) => match self.persister.fetch_swap_by_id(swap_id)? {
Swap::Chain(ChainSwap { claim_tx_id, .. })
| Swap::Receive(ReceiveSwap { claim_tx_id, .. }) => {
match claim_tx_id {
Some(_) => {
// The claim tx has now been broadcast
self.notify_event_listeners(
SdkEvent::PaymentWaitingConfirmation {
details: payment,
},
)
.await?
}
None => {
// The lockup tx is in the mempool/confirmed
self.notify_event_listeners(
SdkEvent::PaymentPending { details: payment },
)
.await?
}
Swap::Chain(ChainSwap { claim_tx_id, .. }) => {
if claim_tx_id.is_some() {
// The claim tx has now been broadcast
self.notify_event_listeners(
SdkEvent::PaymentWaitingConfirmation {
details: payment,
},
)
.await?
} else {
// The lockup tx is in the mempool/confirmed
self.notify_event_listeners(SdkEvent::PaymentPending {
details: payment,
})
.await?
}
}
Swap::Receive(ReceiveSwap {
claim_tx_id,
mrh_tx_id,
..
}) => {
if claim_tx_id.is_some() || mrh_tx_id.is_some() {
// The a claim or mrh tx has now been broadcast
self.notify_event_listeners(
SdkEvent::PaymentWaitingConfirmation {
details: payment,
},
)
.await?
} else {
// The lockup tx is in the mempool/confirmed
self.notify_event_listeners(SdkEvent::PaymentPending {
details: payment,
})
.await?
}
}
Swap::Send(_) => {
Expand Down

0 comments on commit a073084

Please sign in to comment.