Skip to content

Commit e67c160

Browse files
committed
Extend docstring for more types
1 parent 9e57219 commit e67c160

File tree

3 files changed

+68
-8
lines changed

3 files changed

+68
-8
lines changed

src/blockdata/block.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ use crate::blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
3737
use crate::blockdata::script;
3838
use crate::VarInt;
3939

40-
/// A block header, which contains all the block's information except
41-
/// the actual transactions
40+
/// Bitcoin block header.
41+
///
42+
/// Contains all the block's information except the actual transactions, but
43+
/// including a root of a [merkle tree] commiting to all transactions in the block.
44+
///
45+
/// [merkle tree]: https://en.wikipedia.org/wiki/Merkle_tree
4246
///
4347
/// ### Bitcoin Core References
4448
///
@@ -164,8 +168,17 @@ impl BlockHeader {
164168
}
165169
}
166170

167-
/// A Bitcoin block, which is a collection of transactions with an attached
168-
/// proof of work.
171+
/// Bitcoin block.
172+
///
173+
/// A collection of transactions with an attached proof of work.
174+
///
175+
/// See [Bitcoin Wiki: Block][wiki-block] for more information.
176+
///
177+
/// [wiki-block]: https://en.bitcoin.it/wiki/Block
178+
///
179+
/// ### Bitcoin Core References
180+
///
181+
/// * [CBlock definition](https://github.com/bitcoin/bitcoin/blob/345457b542b6a980ccfbc868af0970a6f91d1b82/src/primitives/block.h#L62)
169182
#[derive(PartialEq, Eq, Clone, Debug)]
170183
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
171184
pub struct Block {

src/blockdata/script.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,20 @@ use crate::util::taproot::{LeafVersion, TapBranchHash, TapLeafHash};
4646
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
4747
use crate::schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};
4848

49-
/// A Bitcoin script.
49+
/// Bitcoin script.
50+
///
51+
/// A list of instructions in a simple, [Forth]-like, stack-based programming language
52+
/// that Bitcoin uses.
53+
///
54+
/// [Forth]: https://en.wikipedia.org/wiki/Forth_(programming_language)
55+
///
56+
/// See [Bitcoin Wiki: Script][wiki-script] for more information.
57+
///
58+
/// [wiki-script]: https://en.bitcoin.it/wiki/Script
59+
///
60+
/// ### Bitcoin Core References
61+
///
62+
/// * [CScript definition](https://github.com/bitcoin/bitcoin/blob/d492dc1cdaabdc52b0766bf4cba4bd73178325d0/src/script/script.h#L410)
5063
#[derive(Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash)]
5164
pub struct Script(Box<[u8]>);
5265

src/blockdata/transaction.rs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const UINT256_ONE: [u8; 32] = [
5353
];
5454

5555
/// A reference to a transaction output.
56+
///
57+
/// ### Bitcoin Core References
58+
///
59+
/// * [COutPoint definition](https://github.com/bitcoin/bitcoin/blob/345457b542b6a980ccfbc868af0970a6f91d1b82/src/primitives/transaction.h#L26)
5660
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
5761
pub struct OutPoint {
5862
/// The referenced transaction's txid.
@@ -187,7 +191,15 @@ impl ::core::str::FromStr for OutPoint {
187191
}
188192
}
189193

190-
/// A transaction input, which defines old coins to be consumed
194+
/// Bitcoin transaction input.
195+
///
196+
/// It contains the location of the previous transaction's output,
197+
/// that it spends and set of scripts that satisfy its spending
198+
/// conditions.
199+
///
200+
/// ### Bitcoin Core References
201+
///
202+
/// * [CTxIn definition](https://github.com/bitcoin/bitcoin/blob/345457b542b6a980ccfbc868af0970a6f91d1b82/src/primitives/transaction.h#L65)
191203
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
192204
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
193205
pub struct TxIn {
@@ -220,7 +232,17 @@ impl Default for TxIn {
220232
}
221233
}
222234

223-
/// A transaction output, which defines new coins to be created from old ones.
235+
/// Bitcoin transaction output.
236+
///
237+
/// Defines new coins to be created as a result of the transaction,
238+
/// along with spending conditions ("script", aka "output script"),
239+
/// which an input spending it must satisfy.
240+
///
241+
/// An output that is not yet spent by an input is called Unspent Transaction Output ("UTXO").
242+
///
243+
/// ### Bitcoin Core References
244+
///
245+
/// * [CTxOut definition](https://github.com/bitcoin/bitcoin/blob/345457b542b6a980ccfbc868af0970a6f91d1b82/src/primitives/transaction.h#L148)
224246
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
225247
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
226248
pub struct TxOut {
@@ -237,7 +259,19 @@ impl Default for TxOut {
237259
}
238260
}
239261

240-
/// A Bitcoin transaction, which describes an authenticated movement of coins.
262+
/// Bitcoin transaction.
263+
///
264+
/// An authenticated movement of coins.
265+
///
266+
/// See [Bitcoin Wiki: Transaction][wiki-transaction] for more information.
267+
///
268+
/// [wiki-transaction]: https://en.bitcoin.it/wiki/Transaction
269+
///
270+
/// ### Bitcoin Core References
271+
///
272+
/// * [CTtransaction definition](https://github.com/bitcoin/bitcoin/blob/345457b542b6a980ccfbc868af0970a6f91d1b82/src/primitives/transaction.h#L279)
273+
///
274+
/// ### Serialization notes
241275
///
242276
/// If any inputs have nonempty witnesses, the entire transaction is serialized
243277
/// in the post-BIP141 Segwit format which includes a list of witnesses. If all

0 commit comments

Comments
 (0)