Skip to content

Commit a5dfcd8

Browse files
committed
doc
1 parent cde148a commit a5dfcd8

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

docs/reference/primitives.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,6 +4716,40 @@ export default class TransactionSignature extends Signature {
47164716
47174717
See also: [BigNumber](./primitives.md#class-bignumber), [Signature](./primitives.md#class-signature)
47184718
4719+
#### Method format
4720+
4721+
Formats the SIGHASH preimage for the targeted input, optionally using a cache to skip recomputing shared hash prefixes.
4722+
4723+
```ts
4724+
static format(params: TransactionSignatureFormatParams): number[]
4725+
```
4726+
4727+
Argument Details
4728+
4729+
+ **params**
4730+
+ Context for the signing input plus transaction metadata.
4731+
+ **params.cache**
4732+
+ Optional cache storing previously computed `hashPrevouts`, `hashSequence`, or `hashOutputs*` values; it will be populated if present.
4733+
4734+
#### Method formatBytes
4735+
4736+
Formats the same SIGHASH preimage bytes as `format`, supporting the optional cache for hash reuse.
4737+
4738+
```ts
4739+
static formatBytes(params: TransactionSignatureFormatParams): Uint8Array
4740+
```
4741+
4742+
Returns
4743+
4744+
Bytes for signing.
4745+
4746+
Argument Details
4747+
4748+
+ **params**
4749+
+ Context for the signing operation.
4750+
+ **params.cache**
4751+
+ Optional `SignatureHashCache` that may already contain hashed prefixes and is populated during formatting.
4752+
47194753
#### Method hasLowS
47204754
47214755
Compares to bitcoind's IsLowDERSignature

docs/reference/script.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,12 @@ Argument Details
457457

458458
+ **chunks**
459459
+ =[] - An array of script chunks to directly initialize the script.
460+
+ **rawBytesCache**
461+
+ Optional serialized bytes that can be reused instead of reserializing `chunks`.
462+
+ **hexCache**
463+
+ Optional lowercase hex string that matches the serialized bytes, used to satisfy `toHex` quickly.
464+
+ **parsed**
465+
+ When false the script defers parsing `rawBytesCache` until `chunks` is accessed; defaults to true.
460466

461467
#### Method findAndDelete
462468

src/primitives/TransactionSignature.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,21 @@ export default class TransactionSignature extends Signature {
3939

4040
scope: number
4141

42+
/**
43+
* Formats the SIGHASH preimage for the targeted input, optionally using a cache to skip recomputing shared hash prefixes.
44+
* @param params - Context for the signing input plus transaction metadata.
45+
* @param params.cache - Optional cache storing previously computed `hashPrevouts`, `hashSequence`, or `hashOutputs*` values; it will be populated if present.
46+
*/
4247
static format (params: TransactionSignatureFormatParams): number[] {
4348
return Array.from(this.formatBytes(params))
4449
}
4550

51+
/**
52+
* Formats the same SIGHASH preimage bytes as `format`, supporting the optional cache for hash reuse.
53+
* @param params - Context for the signing operation.
54+
* @param params.cache - Optional `SignatureHashCache` that may already contain hashed prefixes and is populated during formatting.
55+
* @returns Bytes for signing.
56+
*/
4657
static formatBytes (params: TransactionSignatureFormatParams): Uint8Array {
4758
const cache = params.cache
4859
const currentInput = {

src/script/Script.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ export default class Script {
138138
* @constructor
139139
* Constructs a new Script object.
140140
* @param chunks=[] - An array of script chunks to directly initialize the script.
141+
* @param rawBytesCache - Optional serialized bytes that can be reused instead of reserializing `chunks`.
142+
* @param hexCache - Optional lowercase hex string that matches the serialized bytes, used to satisfy `toHex` quickly.
143+
* @param parsed - When false the script defers parsing `rawBytesCache` until `chunks` is accessed; defaults to true.
141144
*/
142145
constructor (chunks: ScriptChunk[] = [], rawBytesCache?: Uint8Array, hexCache?: string, parsed: boolean = true) {
143146
this._chunks = chunks

0 commit comments

Comments
 (0)