Skip to content

Commit f6a8124

Browse files
committed
Add missing gettransaction fields to v17
There are two undocumented fields in wallet v17 gettransaction. They are documented in v20 onwards. Add missing fields trusted and walletconflicts.
1 parent 5da62e7 commit f6a8124

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

types/src/model/wallet.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ pub struct GetTransaction {
285285
pub fee: Option<SignedAmount>,
286286
/// The number of confirmations.
287287
pub confirmations: i64, // Docs do not indicate what negative value means?
288+
/// Whether we consider the outputs of this unconfirmed transaction safe to spend.
289+
pub trusted: Option<bool>,
288290
/// The block hash.
289291
pub block_hash: Option<BlockHash>,
290292
/// The index of the transaction in the block that includes it.
@@ -293,6 +295,8 @@ pub struct GetTransaction {
293295
pub block_time: Option<u32>,
294296
/// The transaction id.
295297
pub txid: Txid,
298+
/// Confirmed transactions that have been detected by the wallet to conflict with this transaction.
299+
pub wallet_conflicts: Vec<Txid>,
296300
/// The transaction time in seconds since epoch (1 Jan 1970 GMT).
297301
pub time: u32,
298302
/// The time received in seconds since epoch (1 Jan 1970 GMT).

types/src/v17/mining/into.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ impl GetBlockTemplate {
1717
use GetBlockTemplateError as E;
1818

1919
let version = block::Version::from_consensus(self.version);
20-
let capabilities = self
21-
.capabilities
22-
.into_iter()
23-
.map(|s| s.to_string())
24-
.collect::<Vec<_>>();
2520
let version_bits_required =
2621
crate::to_u32(self.version_bits_required, "version_bits_required")?;
2722
let previous_block_hash =
@@ -44,7 +39,7 @@ impl GetBlockTemplate {
4439
version,
4540
rules: self.rules,
4641
version_bits_available: self.version_bits_available,
47-
capabilities,
42+
capabilities: self.capabilities,
4843
version_bits_required,
4944
previous_block_hash,
5045
transactions,

types/src/v17/wallet/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ pub enum GetTransactionError {
249249
BlockHash(hex::HexToArrayError),
250250
/// Conversion of the `txid` field failed.
251251
Txid(hex::HexToArrayError),
252+
/// Conversion of the `wallet_conflicts` field failed.
253+
WalletConflicts(hex::HexToArrayError),
252254
/// Conversion of the transaction `hex` field failed.
253255
Tx(encode::FromHexError),
254256
/// Conversion of the `details` field failed.
@@ -265,6 +267,8 @@ impl fmt::Display for GetTransactionError {
265267
E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e),
266268
E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e),
267269
E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e),
270+
E::WalletConflicts(ref e) =>
271+
write_err!(f, "conversion of the `wallet_conflicts` field failed"; e),
268272
E::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e),
269273
E::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e),
270274
}
@@ -282,6 +286,7 @@ impl std::error::Error for GetTransactionError {
282286
E::Fee(ref e) => Some(e),
283287
E::BlockHash(ref e) => Some(e),
284288
E::Txid(ref e) => Some(e),
289+
E::WalletConflicts(ref e) => Some(e),
285290
E::Tx(ref e) => Some(e),
286291
E::Details(ref e) => Some(e),
287292
}

types/src/v17/wallet/into.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ impl GetTransaction {
338338
self.block_index.map(|idx| crate::to_u32(idx, "block_index")).transpose()?;
339339

340340
let txid = self.txid.parse::<Txid>().map_err(E::Txid)?;
341+
let wallet_conflicts = self
342+
.wallet_conflicts
343+
.into_iter()
344+
.map(|s| s.parse::<Txid>().map_err(E::WalletConflicts))
345+
.collect::<Result<Vec<_>, _>>()?;
341346
let tx = encode::deserialize_hex::<Transaction>(&self.hex).map_err(E::Tx)?;
342347
let details = self
343348
.details
@@ -349,10 +354,12 @@ impl GetTransaction {
349354
amount,
350355
fee,
351356
confirmations: self.confirmations,
357+
trusted: self.trusted,
352358
block_hash,
353359
block_index,
354360
block_time: self.block_time,
355361
txid,
362+
wallet_conflicts,
356363
time: self.time,
357364
time_received: self.time_received,
358365
bip125_replaceable: self.bip125_replaceable.into_model(),

types/src/v17/wallet/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ pub struct GetTransaction {
413413
pub fee: Option<f64>,
414414
/// The number of confirmations.
415415
pub confirmations: i64,
416+
/// Whether we consider the outputs of this unconfirmed transaction safe to spend.
417+
pub trusted: Option<bool>,
416418
/// The block hash.
417419
#[serde(rename = "blockhash")]
418420
// The docs say this field should exist but integration test fail without `Option`.
@@ -426,6 +428,9 @@ pub struct GetTransaction {
426428
pub block_time: Option<u32>, // Docs are wrong, this is not documented as optional.
427429
/// The transaction id.
428430
pub txid: String,
431+
/// Confirmed transactions that have been detected by the wallet to conflict with this transaction.
432+
#[serde(rename = "walletconflicts")]
433+
pub wallet_conflicts: Vec<String>,
429434
/// The transaction time in seconds since epoch (1 Jan 1970 GMT).
430435
pub time: u32,
431436
/// The time received in seconds since epoch (1 Jan 1970 GMT).

0 commit comments

Comments
 (0)