Skip to content

Commit

Permalink
Merge pull request #188 from xch-dev/transaction-fix
Browse files Browse the repository at this point in the history
Fix transaction issue
  • Loading branch information
Rigidity authored Dec 24, 2024
2 parents 00b9534 + ce8266f commit a92fbb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/sage-database/src/coin_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'a> DatabaseTx<'a> {
remove_coin_transaction_id(&mut *self.tx, coin_id).await
}

pub async fn is_p2_coin(&mut self, coin_id: Bytes32) -> Result<bool> {
pub async fn is_p2_coin(&mut self, coin_id: Bytes32) -> Result<Option<bool>> {
is_p2_coin(&mut *self.tx, coin_id).await
}
}
Expand Down Expand Up @@ -373,7 +373,7 @@ async fn unspent_cat_coin_ids(conn: impl SqliteExecutor<'_>) -> Result<Vec<Bytes
.collect()
}

async fn is_p2_coin(conn: impl SqliteExecutor<'_>, coin_id: Bytes32) -> Result<bool> {
async fn is_p2_coin(conn: impl SqliteExecutor<'_>, coin_id: Bytes32) -> Result<Option<bool>> {
let coin_id = coin_id.as_ref();

let row = sqlx::query!(
Expand All @@ -384,10 +384,10 @@ async fn is_p2_coin(conn: impl SqliteExecutor<'_>, coin_id: Bytes32) -> Result<b
",
coin_id
)
.fetch_one(conn)
.fetch_optional(conn)
.await?;

Ok(row.kind == 1)
Ok(row.map(|row| row.kind == 1))
}

async fn is_coin_locked(conn: impl SqliteExecutor<'_>, coin_id: Bytes32) -> Result<bool> {
Expand Down
2 changes: 1 addition & 1 deletion crates/sage-wallet/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub async fn safely_remove_transaction(
transaction_id: Bytes32,
) -> Result<(), WalletError> {
for coin_id in tx.transaction_coin_ids(transaction_id).await? {
if !tx.is_p2_coin(coin_id).await? {
if tx.is_p2_coin(coin_id).await? == Some(false) {
tx.unsync_coin(coin_id).await?;
}
}
Expand Down

0 comments on commit a92fbb3

Please sign in to comment.