Skip to content

Commit

Permalink
Add extra check to not sign txs with same inputs, add eyre auto-insta…
Browse files Browse the repository at this point in the history
…ll feature
  • Loading branch information
Thoralf-M committed Mar 1, 2024
1 parent 51ced43 commit 3c1af3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dialoguer = { version = "0.11.0", default-features = false, features = [
"password",
] }
dotenvy = { version = "0.15.7", default-features = false }
eyre = { version = "0.6.12", default-features = false }
eyre = { version = "0.6.12", default-features = false, features = ["auto-install"] }
fern-logger = { version = "0.5.0", default-features = false }
log = { version = "0.4.20", default-features = false }
prefix-hex = { version = "0.7.1", default-features = false, features = ["std"] }
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/wallet/operations/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ where
) -> crate::wallet::Result<TransactionWithMetadata> {
log::debug!("[TRANSACTION] sign_and_submit_transaction");

let wallet_ledger = self.ledger().await;
// check if inputs got already used by another transaction
for output in &prepared_transaction_data.inputs_data {
if wallet_ledger.locked_outputs.contains(output.output_id()) {
return Err(crate::wallet::Error::CustomInput(format!(
"provided input {} is already used in another transaction",
output.output_id()
)));
};
}
drop(wallet_ledger);

let signed_transaction_data = self.sign_transaction(&prepared_transaction_data).await?;

self.submit_and_store_transaction(signed_transaction_data, options)
Expand Down

0 comments on commit 3c1af3f

Please sign in to comment.