Skip to content

Commit 0bd1328

Browse files
committed
Merge branch '2024-08--docs'
2 parents b21356e + a3af727 commit 0bd1328

File tree

10 files changed

+61
-22
lines changed

10 files changed

+61
-22
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ jobs:
6969
run: ./contrib/test.sh
7070

7171
Fuzz:
72-
name: Fuzztests - 1.58.0 toolchain
72+
name: Fuzztests - 1.63.0 toolchain
7373
runs-on: ubuntu-latest
7474
strategy:
7575
fail-fast: false
7676
steps:
7777
- name: Checkout Crate
7878
uses: actions/checkout@v3
7979
- name: Checkout Toolchain
80-
uses: dtolnay/rust-toolchain@1.58.0
80+
uses: dtolnay/rust-toolchain@1.63.0
8181
- name: Install test dependencies
8282
run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
8383
- name: Running test script

contrib/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ if cargo --version | grep "1\.56"; then
99
cargo update -p which --precise 4.4.0
1010
cargo update -p byteorder --precise 1.4.3
1111
cargo update -p cc --precise 1.0.94
12+
cargo update -p serde_json --precise 1.0.98
13+
cargo update -p serde --precise 1.0.156
14+
cargo update -p ppv-lite86 --precise 0.2.8
1215
fi
1316

1417
if [ "$DO_FEATURE_MATRIX" = true ]

src/blind.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ impl TxOutSecrets {
262262
}
263263
}
264264

265-
/// Gets the surjection inputs from [`TxOutSecrets`]
265+
/// Gets the surjection inputs from [`TxOutSecrets`].
266+
///
266267
/// Returns a tuple (assetid, blind_factor, generator) if the blinds are
267268
/// consistent with asset commitment
268269
/// Otherwise, returns an error
@@ -280,6 +281,7 @@ impl TxOutSecrets {
280281
}
281282

282283
/// Data structure used to provide inputs to [`SurjectionProof`] methods.
284+
///
283285
/// Inputs for which we don't know the secrets can be [`SurjectionInput::Unknown`],
284286
/// while inputs from user's wallet should be [`SurjectionInput::Known`]
285287
///

src/encode.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ impl Encodable for Vec<u8> {
403403
impl Decodable for Vec<u8> {
404404
fn consensus_decode<D: crate::ReadExt>(mut d: D) -> Result<Self, Error> {
405405
let s = VarInt::consensus_decode(&mut d)?.0 as usize;
406+
if s > MAX_VEC_SIZE {
407+
return Err(self::Error::OversizedVectorAllocation {
408+
requested: s,
409+
max: MAX_VEC_SIZE,
410+
});
411+
}
406412
let mut v = vec![0; s];
407413
d.read_slice(&mut v)?;
408414
Ok(v)

src/fast_merkle_root.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn sha256midstate(left: &[u8], right: &[u8]) -> sha256::Midstate {
2424
}
2525

2626
/// Compute the Merkle root of the give hashes using mid-state only.
27+
///
2728
/// The inputs must be byte slices of length 32.
2829
/// Note that the merkle root calculated with this method is not the same as the
2930
/// one computed by a normal SHA256(d) merkle root.

src/hash_types.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
//
1414

15-
//! File defines types for hashes used throughout the library. These types are needed in order
15+
//! File defines types for hashes used throughout the library.
16+
//!
17+
//! These types are needed in order
1618
//! to avoid mixing data of the same hash format (like SHA256d) but of different meaning
1719
//! (transaction id, block hash etc).
1820

src/opcodes.rs

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,20 @@ pub mod all {
448448
/// and completing the padding
449449
pub const OP_SHA256FINALIZE: All = All {code: 0xc6};
450450
/// Pop a CScriptNum input index idx and push the outpoint as a tuple.
451+
///
451452
/// First push the txid(32) of the prev_out, followed by a 4 byte push of
452453
/// vout followed by a push for the outpoint_flag(1)
453454
pub const OP_INSPECTINPUTOUTPOINT: All = All {code: 0xc7};
454455
/// Pop a CScriptNum input index idx and push the nAsset onto the stack as two elements.
456+
///
455457
/// The first push the assetID(32), followed by the prefix(1)
456458
pub const OP_INSPECTINPUTASSET: All = All {code: 0xc8};
457459
/// Pop a CScriptNum input index idx and push the nValue as a tuple,
460+
///
458461
/// value(8 byte LE, 32) followed by prefix(1),
459462
pub const OP_INSPECTINPUTVALUE: All = All {code: 0xc9};
460463
/// Pop a CScriptNum input index idx and push the following depending the type of scriptPubkey:
464+
///
461465
/// - If the scriptPubKey is not a native segwit program, push a single sha256
462466
/// hash of the scriptPubKey on stack top. Next, push a CScriptNum(-1) to
463467
/// indicate a non-native segwit scriptPubKey.
@@ -467,7 +471,9 @@ pub mod all {
467471
/// Pop a CScriptNum input index idx and push the nSequence(4) as little-endian number.
468472
pub const OP_INSPECTINPUTSEQUENCE: All = All {code: 0xcb};
469473
/// Pop a CScriptNum input index idx and push the assetIssuance information if the asset has issuance,
470-
/// otherwise push an empty vector. Refer to the [spec](https://github.com/ElementsProject/elements/blob/master/doc/tapscript_opcodes.md)
474+
/// otherwise push an empty vector.
475+
///
476+
/// Refer to the [spec](https://github.com/ElementsProject/elements/blob/master/doc/tapscript_opcodes.md)
471477
/// for details
472478
pub const OP_INSPECTINPUTISSUANCE: All = All {code: 0xcc};
473479
/// Pushes the current input index as CScriptNum. This can be used in conjunction with
@@ -496,18 +502,22 @@ pub mod all {
496502
/// Push the transaction weight (8) as little-endian
497503
pub const OP_TXWEIGHT: All = All {code: 0xd6};
498504
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE).
505+
///
499506
/// Push a + b onto the stack. Push 1 CScriptNum if there is no overflow.
500507
/// Refer to the spec for details when dealing with overflow.
501508
pub const OP_ADD64: All = All {code: 0xd7};
502-
/// pop the first number(8 byte LE) as b followed another pop for a(8 byte LE).
509+
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE).
510+
///
503511
/// Push a - b onto the stack. Push 1 CScriptNum if there is no overflow.
504512
/// Refer to the spec for details when dealing with overflow.
505513
pub const OP_SUB64: All = All {code: 0xd8};
506514
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE).
515+
///
507516
/// Push a*b onto the stack. Push 1 CScriptNum if there is no overflow.
508517
/// Refer to the spec for details when dealing with overflow.
509518
pub const OP_MUL64: All = All {code: 0xd9};
510-
/// pop the first number(8 byte LE) as b followed another pop for a(8 byte LE).
519+
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE).
520+
///
511521
/// First push remainder a%b(must be non-negative and less than |b|) onto the
512522
/// stack followed by quotient(a//b) onto the stack.
513523
///
@@ -516,44 +526,54 @@ pub mod all {
516526
/// Refer to the spec for details when dealing with overflow.
517527
pub const OP_DIV64: All = All {code: 0xda};
518528
/// Pop the first number(8 byte LE) as a and pushes -a on the stack top.
529+
///
519530
/// If the number is -2^63 treat as overflow, otherwise push CScriptNum 1 to indicate no overflow.
520531
/// Refer to the spec for details when dealing with overflow.
521532
pub const OP_NEG64: All = All {code: 0xdb};
522-
/// pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a < b.
533+
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a < b.
534+
///
523535
/// Note that this operation cannot fail
524536
pub const OP_LESSTHAN64: All = All {code: 0xdc};
525-
/// pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a <= b.
537+
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a <= b.
538+
///
526539
/// Note that this operation cannot fail
527540
pub const OP_LESSTHANOREQUAL64: All = All {code: 0xdd};
528-
/// pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a > b
541+
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a > b.
542+
///
529543
/// Note that this operation cannot fail
530544
pub const OP_GREATERTHAN64: All = All {code: 0xde};
531-
/// pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a >= b.
545+
/// Pop the first number(8 byte LE) as b followed another pop for a(8 byte LE). Push a >= b.
532546
/// Note that this operation cannot fail
533547
pub const OP_GREATERTHANOREQUAL64: All = All {code: 0xdf};
534-
/// pop the stack as minimal CScriptNum, push 8 byte signed LE corresponding to that number.
548+
/// Pop the stack as minimal CScriptNum, push 8 byte signed LE corresponding to that number.
535549
pub const OP_SCRIPTNUMTOLE64: All = All {code: 0xe0};
536-
/// pop the stack as a 8 byte signed LE. Convert to CScriptNum and push it, abort on fail.
550+
/// Pop the stack as a 8 byte signed LE. Convert to CScriptNum and push it, abort on fail.
551+
///
537552
/// Please check the range of the operand before calling the opcode.
538553
pub const OP_LE64TOSCRIPTNUM: All = All {code: 0xe1};
539-
/// pop the stack as a 4 byte unsigned LE. Push the corresponding 8 byte signed LE number.
554+
/// Pop the stack as a 4 byte unsigned LE. Push the corresponding 8 byte signed LE number.
555+
///
540556
/// Cannot fail, useful for operating of version, locktime, sequence, number of inputs,
541557
/// number of outputs, weight etc.
542558
pub const OP_LE32TOLE64: All = All {code: 0xe2};
543-
/// Pops three elements from stack as described below:
544-
/// 1) a 32 byte big endian, unsigned scalar k.
545-
/// 2) Compressed EC point P, and
546-
/// 3) compressed EC point Q.
559+
/// Pops three elements from stack as:
560+
///
561+
/// 1. a 32 byte big endian, unsigned scalar k.
562+
/// 2. Compressed EC point P, and
563+
/// 3. compressed EC point Q.
547564
///
548565
/// Abort if P, Q is invalid or k is not 32 bytes and outside of secp256k1 curve order.
566+
///
549567
/// Abort if Q != k*P.
550568
pub const OP_ECMULSCALARVERIFY: All = All {code: 0xe3};
551569
/// Pop the three elements as:
552-
/// 1) 32 byte X-only internal key P,
553-
/// 2) a 32 byte big endian, unsigned scalar k, and
554-
/// 3) 33 byte compressed point Q.
570+
///
571+
/// 1. 32 byte X-only internal key P,
572+
/// 2. a 32 byte big endian, unsigned scalar k, and
573+
/// 3. 33 byte compressed point Q.
555574
///
556575
/// Abort if P, Q is invalid or k is not 32 bytes and outside of secp256k1 curve order.
576+
///
557577
/// Abort if Q != P + k*G where G is the generator for secp256k1.
558578
pub const OP_TWEAKVERIFY: All = All {code: 0xe4};
559579
/// Synonym for OP_RETURN

src/pset/map/input.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ impl Default for Input {
321321
}
322322
}
323323

324-
/// A Signature hash type for the corresponding input. As of taproot upgrade, the signature hash
324+
/// A Signature hash type for the corresponding input.
325+
///
326+
/// As of taproot upgrade, the signature hash
325327
/// type can be either [`EcdsaSighashType`] or [`SchnorrSighashType`] but it is not possible to know
326328
/// directly which signature hash type the user is dealing with. Therefore, the user is responsible
327329
/// for converting to/from [`PsbtSighashType`] from/to the desired signature hash type they need.

src/script.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,14 @@ fn build_scriptint(n: i64) -> Vec<u8> {
178178
}
179179

180180
/// Helper to decode an integer in script format
181+
///
181182
/// Notice that this fails on overflow: the result is the same as in
182183
/// bitcoind, that only 4-byte signed-magnitude values may be read as
183184
/// numbers. They can be added or subtracted (and a long time ago,
184185
/// multiplied and divided), and this may result in numbers which
185186
/// can't be written out in 4 bytes or less. This is ok! The number
186187
/// just can't be read as a number again.
188+
///
187189
/// This is a bit crazy and subtle, but it makes sense: you can load
188190
/// 32-bit numbers and do anything with them, which back when mult/div
189191
/// was allowed, could result in up to a 64-bit number. We don't want

src/taproot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub const TAPROOT_CONTROL_MAX_SIZE: usize =
103103
// type alias for versioned tap script corresponding merkle proof
104104
type ScriptMerkleProofMap = BTreeMap<(Script, LeafVersion), BTreeSet<TaprootMerkleBranch>>;
105105
/// Data structure for representing Taproot spending information.
106+
///
106107
/// Taproot output corresponds to a combination of a
107108
/// single public key condition (known the internal key), and zero or more
108109
/// general conditions encoded in scripts organized in the form of a binary tree.

0 commit comments

Comments
 (0)