Skip to content

Commit

Permalink
fix(wallet-history): wait for confirmations to show txs as successful
Browse files Browse the repository at this point in the history
  • Loading branch information
Restioson committed Sep 13, 2023
1 parent f612d37 commit 789eb7f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ mod node;

pub mod channel_status;

use crate::api::Status;
pub use channel_status::ChannelStatus;

const PROCESS_INCOMING_DLC_MESSAGES_INTERVAL: Duration = Duration::from_millis(200);
Expand Down Expand Up @@ -301,9 +302,8 @@ fn keep_wallet_balance_and_history_up_to_date(node: &Node) -> Result<()> {
(api::PaymentFlow::Outbound, net_sats.unsigned_abs())
};

let (status, timestamp, n_confirmations) = match details.confirmation_time {
let (timestamp, n_confirmations) = match details.confirmation_time {
Some(BlockTime { timestamp, height }) => (
api::Status::Confirmed,
timestamp,
// This is calculated manually to avoid wasteful requests to esplora,
// since we can just cache the blockchain height as opposed to fetching it for each
Expand All @@ -315,14 +315,19 @@ fn keep_wallet_balance_and_history_up_to_date(node: &Node) -> Result<()> {

None => {
(
api::Status::Pending,
// Unconfirmed transactions should appear towards the top of the history
OffsetDateTime::now_utc().unix_timestamp() as u64,
0,
)
}
};

let status = if n_confirmations >= 3 {
Status::Confirmed
} else {
Status::Pending
};

let wallet_type = api::WalletHistoryItemType::OnChain {
txid: details.txid.to_string(),
fee_sats: details.fee,
Expand Down

0 comments on commit 789eb7f

Please sign in to comment.