Skip to content

Commit adc694b

Browse files
committed
Merge #243: Add missing return fields in v17
e9575cd Run the formatter (Jamil Lambert, PhD) f6a8124 Add missing gettransaction fields to v17 (Jamil Lambert, PhD) 5da62e7 Add missing decodescript field to v17 (Jamil Lambert, PhD) 60f8e75 Add missing getblocktemplate fields to v17 (Jamil Lambert, PhD) Pull request description: When looking into the fix for #241 some missing fields in the v17 types were found. Add the missing fields. Remove the now unnecessary change in v29 to `getblocktemplate` since the fields have been there since v17, just undocumented. ACKs for top commit: tcharding: ACK e9575cd Tree-SHA512: e6826e317ebc5d8bb568e765a44e9f4da4b2822280edb446e644f32c24b17d71e8c2bf69fbdf5d42a76e0cedf204083114e6913ca3eb1f8d313a3ef3207e5582
2 parents 41f3ca8 + e9575cd commit adc694b

File tree

14 files changed

+62
-217
lines changed

14 files changed

+62
-217
lines changed

types/src/model/mining.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub struct GetBlockTemplate {
2424
/// Map of rules name to bit number - identifies the bit number as indicating acceptance and
2525
/// readiness for the named softfork rule.
2626
pub version_bits_available: BTreeMap<String, u32>,
27+
/// Client side supported features.
28+
pub capabilities: Vec<String>,
2729
/// Bit mask of versionbits the server requires set in submissions.
2830
pub version_bits_required: u32,
2931
/// The hash of current highest block.
@@ -37,6 +39,8 @@ pub struct GetBlockTemplate {
3739
/// Maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis).
3840
#[serde(with = "bitcoin::amount::serde::as_sat")]
3941
pub coinbase_value: SignedAmount,
42+
/// An id to include with a request to longpoll on an update to this template.
43+
pub long_poll_id: Option<String>,
4044
/// The hash target.
4145
pub target: Vec<u8>,
4246
/// The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT).
@@ -59,6 +63,10 @@ pub struct GetBlockTemplate {
5963
pub bits: CompactTarget,
6064
/// The height of the next block,
6165
pub height: u32,
66+
/// Optional signet challenge
67+
pub signet_challenge: Option<String>,
68+
/// A valid witness commitment for the unmodified block template.
69+
pub default_witness_commitment: Option<String>,
6270
}
6371

6472
/// Contents of non-coinbase transactions that should be included in the next block.

types/src/model/raw_transactions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ pub struct DecodeScript {
101101
pub addresses: Vec<Address<NetworkUnchecked>>,
102102
/// Address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).
103103
pub p2sh: Option<Address<NetworkUnchecked>>,
104+
/// Address of the P2SH script wrapping this witness redeem script
105+
pub p2sh_segwit: Option<String>,
104106
}
105107

106108
/// Models the result of JSON-RPC method `descriptorprocesspsbt`.

types/src/model/wallet.rs

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

types/src/v17/mining/into.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ impl GetBlockTemplate {
3939
version,
4040
rules: self.rules,
4141
version_bits_available: self.version_bits_available,
42+
capabilities: self.capabilities,
4243
version_bits_required,
4344
previous_block_hash,
4445
transactions,
4546
coinbase_aux: self.coinbase_aux,
4647
coinbase_value,
48+
long_poll_id: self.long_poll_id,
4749
target,
4850
min_time: self.min_time,
4951
mutable: self.mutable,
@@ -54,6 +56,8 @@ impl GetBlockTemplate {
5456
current_time: self.current_time,
5557
bits,
5658
height,
59+
signet_challenge: self.signet_challenge,
60+
default_witness_commitment: self.default_witness_commitment,
5761
})
5862
}
5963
}

types/src/v17/mining/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub struct GetBlockTemplate {
5353
/// readiness for the named softfork rule.
5454
#[serde(rename = "vbavailable")]
5555
pub version_bits_available: BTreeMap<String, u32>,
56+
/// Client side supported features.
57+
pub capabilities: Vec<String>,
5658
/// Bit mask of versionbits the server requires set in submissions.
5759
#[serde(rename = "vbrequired")]
5860
pub version_bits_required: i64,
@@ -69,6 +71,9 @@ pub struct GetBlockTemplate {
6971
/// Maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis).
7072
#[serde(rename = "coinbasevalue")]
7173
pub coinbase_value: i64,
74+
/// An id to include with a request to longpoll on an update to this template.
75+
#[serde(rename = "longpollid")]
76+
pub long_poll_id: Option<String>,
7277
// This is in the docs but not actually returned (for v0.17 and v0.18 at least).
7378
// coinbase_txn: ???, // Also I don't know what the JSON object represents: `{ ... }`
7479
/// The hash target.
@@ -78,7 +83,7 @@ pub struct GetBlockTemplate {
7883
pub min_time: u32,
7984
/// List of ways the block template may be changed.
8085
///
81-
/// A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'
86+
/// A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'.
8287
pub mutable: Vec<String>,
8388
/// A range of valid nonces.
8489
#[serde(rename = "noncerange")]
@@ -97,8 +102,12 @@ pub struct GetBlockTemplate {
97102
pub current_time: u64,
98103
/// Compressed target of next block.
99104
pub bits: String,
100-
/// The height of the next block,
105+
/// The height of the next block.
101106
pub height: i64,
107+
/// Optional signet challenge.
108+
pub signet_challenge: Option<String>,
109+
/// A valid witness commitment for the unmodified block template.
110+
pub default_witness_commitment: Option<String>,
102111
}
103112

104113
/// Contents of non-coinbase transactions that should be included in the next block.

types/src/v17/raw_transactions/into.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ impl DecodeScript {
307307
required_signatures: self.required_signatures,
308308
addresses,
309309
p2sh,
310+
p2sh_segwit: self.p2sh_segwit,
310311
})
311312
}
312313
}

types/src/v17/raw_transactions/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ pub struct DecodeScript {
219219
pub p2sh: Option<String>,
220220
/// Segwit data (see `DecodeScriptSegwit` for explanation).
221221
pub segwit: Option<DecodeScriptSegwit>,
222+
/// Address of the P2SH script wrapping this witness redeem script
223+
#[serde(rename = "p2sh-segwit")]
224+
pub p2sh_segwit: Option<String>,
222225
}
223226

224227
/// Seemingly undocumented data returned in the `segwit` field of `DecodeScript`.
@@ -238,6 +241,7 @@ pub struct DecodeScriptSegwit {
238241
/// List of bitcoin addresses.
239242
pub addresses: Option<Vec<String>>,
240243
/// Address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).
244+
#[serde(rename = "p2sh-segwit")]
241245
pub p2sh_segtwit: Option<String>,
242246
}
243247

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)