Skip to content

Commit eb03642

Browse files
Merge #5: Let get_output_status use a u64 for the index.
78dbc20 Let `get_output_status` use a `u64` for the index (Elias Rohrer) Pull request description: Unfortunately #4 had a minor bug as the `get_output_status` API method doesn't require a full `struct Vout` as input and doesn't return the data to populate a full `struct Vin`. This PR fixes this by just using `u64` for the respective index fields. Now tested to work with both the `blocking` and `async` variant. Top commit has no ACKs. Tree-SHA512: 9c4fa354a208eec717ffa37ae6d07a20b454712aef03565b7dc4c33e4dd2db5142d2d3734ea4319e1286eacacc26f5a551d820f67642e36f5defa702f0530538
2 parents 5a14886 + 78dbc20 commit eb03642

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct MerkleProof {
5151
pub struct OutputStatus {
5252
spent: bool,
5353
txid: Option<Txid>,
54-
vin: Option<Vin>,
54+
vin: Option<u64>,
5555
status: Option<TxStatus>,
5656
}
5757

src/async.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use log::{debug, error, info, trace};
2323

2424
use reqwest::{Client, StatusCode};
2525

26-
use crate::{Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus, Vout};
26+
use crate::{Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus};
2727

2828
#[derive(Debug)]
2929
pub struct AsyncClient {
@@ -134,15 +134,15 @@ impl AsyncClient {
134134
Ok(Some(resp.error_for_status()?.json().await?))
135135
}
136136

137-
/// Get the spending status of an output given a [`Txid`] and [`Vout`].
137+
/// Get the spending status of an output given a [`Txid`] and the output index.
138138
pub async fn get_output_status(
139139
&self,
140140
txid: &Txid,
141-
vout: &Vout,
141+
index: u64,
142142
) -> Result<Option<OutputStatus>, Error> {
143143
let resp = self
144144
.client
145-
.get(&format!("{}/tx/{}/outspend/{}", self.url, txid, vout.value))
145+
.get(&format!("{}/tx/{}/outspend/{}", self.url, txid, index))
146146
.send()
147147
.await?;
148148

src/blocking.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use bitcoin::hashes::hex::{FromHex, ToHex};
2626
use bitcoin::hashes::{sha256, Hash};
2727
use bitcoin::{BlockHeader, Script, Transaction, Txid};
2828

29-
use crate::{Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus, Vout};
29+
use crate::{Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus};
3030

3131
#[derive(Debug, Clone)]
3232
pub struct BlockingClient {
@@ -149,15 +149,15 @@ impl BlockingClient {
149149
}
150150
}
151151

152-
/// Get the spending status of an output given a [`Txid`] and [`Vout`].
152+
/// Get the spending status of an output given a [`Txid`] and the output index.
153153
pub fn get_output_status(
154154
&self,
155155
txid: &Txid,
156-
vout: &Vout,
156+
index: u64,
157157
) -> Result<Option<OutputStatus>, Error> {
158158
let resp = self
159159
.agent
160-
.get(&format!("{}/tx/{}/outspend/{}", self.url, txid, vout.value))
160+
.get(&format!("{}/tx/{}/outspend/{}", self.url, txid, index))
161161
.call();
162162

163163
match resp {

0 commit comments

Comments
 (0)