Skip to content

Commit

Permalink
doc(wallet): Fixup docs for insert_tx
Browse files Browse the repository at this point in the history
and add a disclaimer about safety for
`Wallet::tx_graph_mut`
  • Loading branch information
ValuedMammal committed May 23, 2024
1 parent 1bbd487 commit c547aa4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,11 @@ impl Wallet {
/// which will be false if the same transaction already exists in the wallet's transaction
/// graph. Any changes will be staged but not committed.
///
/// **WARNING**: manually inserting a transaction can influence the wallet's utxos and pending
/// balance if the tx is relevant to this wallet, but you won't know whether the resulting
/// txouts exist on chain until the tx is broadcast and the wallet synced via a chain source.
/// # Note
///
/// By default the inserted `tx` won't be considered "canonical" because it's not known
/// whether the transaction exists in the best chain. To know whether it exists, the tx
/// must be broadcast to the network and the wallet synced via a chain source.
pub fn insert_tx(&mut self, tx: Transaction) -> bool {
let mut changeset = ChangeSet::default();
changeset.append(self.indexed_graph.insert_tx(tx).into());
Expand Down Expand Up @@ -2432,6 +2434,11 @@ impl Wallet {
}

/// Get a mutable reference to the inner [`TxGraph`].
///
/// **WARNING**: It's not recommended to make changes manually to the transaction
/// graph unless you know what you're doing, because it can cause the wallet to get
/// into a bad state. Changes to the inner [`TxGraph`] happen naturally as a result
/// of syncing with an external chain source and applying updates to the wallet.
pub fn tx_graph_mut(&mut self) -> &mut TxGraph<ConfirmationTimeHeightAnchor> {
self.indexed_graph.graph_mut()
}
Expand Down

0 comments on commit c547aa4

Please sign in to comment.