Skip to content

refactor: replace specialized types, which used in APIs, with primitive rust types #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions prover/src/tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,17 @@ fn test_spv_client(

log::debug!(">>> with confirmations {confirmations}");

let txid_array = txid.as_ref();
let verify_result = tip_client
.verify_transaction(&txid, tx_proof.as_reader(), confirmations - 1)
.verify_transaction(txid_array, tx_proof.as_reader(), confirmations - 1)
.map_err(|err| err as i8);
assert!(verify_result.is_ok());
let verify_result = tip_client
.verify_transaction(&txid, tx_proof.as_reader(), confirmations)
.verify_transaction(txid_array, tx_proof.as_reader(), confirmations)
.map_err(|err| err as i8);
assert!(verify_result.is_ok());
let verify_result = tip_client
.verify_transaction(&txid, tx_proof.as_reader(), confirmations + 1)
.verify_transaction(txid_array, tx_proof.as_reader(), confirmations + 1)
.map_err(|err| err as i8);
assert!(verify_result.is_err());
}
Expand Down
9 changes: 5 additions & 4 deletions verifier/src/types/extension/packed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl packed::SpvClient {
let tx: core::Transaction =
deserialize(tx).map_err(|_| VerifyTxError::DecodeTransaction)?;
let txid = tx.txid();
let header = self.verify_transaction(&txid, tx_proof, confirmations)?;
let header = self.verify_transaction(txid.as_ref(), tx_proof, confirmations)?;
Ok((header, tx))
}

Expand All @@ -286,7 +286,7 @@ impl packed::SpvClient {
/// If you don't need it, just ignore it.
pub fn verify_transaction(
&self,
txid: &core::Txid,
txid: &[u8; 32],
tx_proof: packed::TransactionProofReader,
confirmations: u32,
) -> Result<core::Header, VerifyTxError> {
Expand Down Expand Up @@ -328,8 +328,9 @@ impl packed::SpvClient {
.position(|v| v == tx_index)
.map(|i| matches[i])
.ok_or(VerifyTxError::TxOutProofInvalidTxIndex)
.and_then(|ref id| {
if id == txid {
.and_then(|id| {
let id_bytes: &[u8; 32] = id.as_ref();
if id_bytes == txid {
Ok(())
} else {
Err(VerifyTxError::TxOutProofInvalidTxId)
Expand Down
Loading