Skip to content

Commit 3fb91e9

Browse files
committed
rust: TxNotFound use BETxid
1 parent 13054bd commit 3fb91e9

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

subprojects/gdk_rust/gdk_electrum/src/account.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,7 @@ impl Account {
361361
let store_read = self.store.read()?;
362362
let acc_store = store_read.account_cache(self.account_num)?;
363363

364-
let txe =
365-
acc_store.all_txs.get(&txid).ok_or_else(|| Error::TxNotFound(txid.to_string()))?;
364+
let txe = acc_store.all_txs.get(&txid).ok_or_else(|| Error::TxNotFound(txid))?;
366365
let tx = &txe.tx;
367366
let height = acc_store.heights.get(&txid).cloned().flatten().unwrap_or(0);
368367
let account_path = acc_store.get_path(&tx.output_script(vout))?;
@@ -1032,8 +1031,7 @@ pub fn create_tx(
10321031
let acc_store = store_read.account_cache(account.num())?;
10331032

10341033
let txid = BETxid::from_hex(&prev_txitem.txhash, network.id())?;
1035-
let prev_tx =
1036-
&acc_store.all_txs.get(&txid).ok_or_else(|| Error::TxNotFound(txid.to_string()))?.tx;
1034+
let prev_tx = &acc_store.all_txs.get(&txid).ok_or_else(|| Error::TxNotFound(txid))?.tx;
10371035

10381036
// Strip the mining fee change output from the transaction, keeping the change address for reuse
10391037
template_tx = Some(prev_tx.filter_outputs(&acc_store.unblinded, |vout, script, asset| {

subprojects/gdk_rust/gdk_electrum/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::store::StoreMeta;
2-
use crate::State;
2+
use crate::{BETxid, State};
33
use aes_gcm_siv::aead;
44
use serde::ser::Serialize;
55
use std::convert::From;
@@ -33,7 +33,7 @@ pub enum Error {
3333
StoreNotLoaded,
3434
WalletNotInitialized,
3535
MissingMasterBlindingKey,
36-
TxNotFound(String),
36+
TxNotFound(BETxid),
3737
ScriptPubkeyNotFound,
3838
AddrParse(String),
3939
InvalidElectrumUrl(String),

subprojects/gdk_rust/gdk_electrum/src/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl StoreMeta {
460460
return Ok(tx_entry);
461461
}
462462
}
463-
Err(Error::TxNotFound(txid.to_string()))
463+
Err(Error::TxNotFound(txid.clone()))
464464
}
465465
}
466466

0 commit comments

Comments
 (0)