Skip to content

Commit 1db611a

Browse files
committed
Merge #89: Add missing transaction categories
f31fe46 Add missing transaction categories (Elias Rohrer) Pull request description: Contrary to Bitcoin Core's v17 docs, there are *five* transaction categories that might be returned as part of a response to `listtransactions`, `listsinceblock`, or `gettransaction`. While Core fixed this omission in the docs in bitcoin/bitcoin#14653, we didn't account for them in the respective model's `enum`, leading to calls to `get_transaction` randomly failing with the rather obscure error message: ``` Err(JsonRpc(Json(Error("unknown variant `generate`, expected `send` or `receive`", line: 1, column: 682)))) ``` Here, we fix this omission and add the missing categories. Note that while the doc fix bitcoin/bitcoin#14653 was shipped as part of `v18`, the categories are pre-existing, which is why we simply fix the `v17` and `model` variants in-place here. @tcharding This might warrant a patch release, IMO? ACKs for top commit: tcharding: ACK f31fe46 Tree-SHA512: cfadb9862c25d7e871426c53b083d162b2a336ea4cc37b7d5c6be69f47147c13a0df86a02f7af3838a691f8fb692c12e1f3c2fb41e05b22ef7d68b4b75da48f8
2 parents 7949505 + f31fe46 commit 1db611a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

types/src/model/wallet.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ pub enum AddressPurpose {
2727
/// The category of a transaction.
2828
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
2929
pub enum TransactionCategory {
30-
/// Transaction is a send.
30+
/// Transactions sent.
3131
Send,
32-
/// Transactions is a receive.
32+
/// Non-coinbase transactions received.
3333
Receive,
34+
/// Coinbase transactions received with more than 100 confirmations.
35+
Generate,
36+
/// Coinbase transactions received with 100 or fewer confirmations.
37+
Immature,
38+
/// Orphaned coinbase transactions received.
39+
Orphan,
3440
}
3541

3642
/// Whether this transaction can be RBF'ed.

types/src/v17/wallet/into.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ impl TransactionCategory {
3737
match self {
3838
V::Send => M::Send,
3939
V::Receive => M::Receive,
40+
V::Generate => M::Generate,
41+
V::Immature => M::Immature,
42+
V::Orphan => M::Orphan,
4043
}
4144
}
4245
}

types/src/v17/wallet/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ pub enum AddressPurpose {
3838
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
3939
#[serde(rename_all = "lowercase")]
4040
pub enum TransactionCategory {
41-
/// Transaction is a send.
41+
/// Transactions sent.
4242
Send,
43-
/// Transactions is a receive.
43+
/// Non-coinbase transactions received.
4444
Receive,
45+
/// Coinbase transactions received with more than 100 confirmations.
46+
Generate,
47+
/// Coinbase transactions received with 100 or fewer confirmations.
48+
Immature,
49+
/// Orphaned coinbase transactions received.
50+
Orphan,
4551
}
4652

4753
/// Whether this transaction can be RBF'ed.

0 commit comments

Comments
 (0)