Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Mistakes and bugs happen, but with your help in resolving and reporting [issues]
- Easy to audit and verify,
- Tested, with test coverage >95%,
- Advanced and feature rich,
- Standardized, using [prettier](https://github.com/prettier/prettier) and Node `Buffer`'s throughout, and
- Standardized, using [prettier](https://github.com/prettier/prettier) and Uint8Array (with node `Buffer` supported as a Uint8Array subclass) throughout, and
- Friendly, with a strong and helpful community, ready to answer questions.

## Documentation
Expand Down
4 changes: 2 additions & 2 deletions ts_src/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export function toBech32(

/**
* Converts an output script to a Bitcoin address.
* @param output - The output script as a Buffer.
* @param output - The output script as a Uint8Array (node Buffer is also accepted).
* @param network - The Bitcoin network (optional).
* @returns The Bitcoin address corresponding to the output script.
* @throws If the output script has no matching address.
Expand Down Expand Up @@ -209,7 +209,7 @@ export function fromOutputScript(
* Converts a Bitcoin address to its corresponding output script.
* @param address - The Bitcoin address to convert.
* @param network - The Bitcoin network to use. Defaults to the Bitcoin network.
* @returns The corresponding output script as a Buffer.
* @returns The corresponding output script as a Uint8Array.
* @throws If the address has an invalid prefix or no matching script.
*/
export function toOutputScript(address: string, network?: Network): Uint8Array {
Expand Down
4 changes: 2 additions & 2 deletions ts_src/payments/bip341.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function findScriptPath(
/**
* Calculates the tapleaf hash for a given Tapleaf object.
* @param leaf - The Tapleaf object to calculate the hash for.
* @returns The tapleaf hash as a Buffer.
* @returns The tapleaf hash as a Uint8Array.
*/
export function tapleafHash(leaf: Tapleaf): Uint8Array {
const version = leaf.version || LEAF_VERSION_TAPSCRIPT;
Expand Down Expand Up @@ -178,7 +178,7 @@ function tapBranchHash(a: Uint8Array, b: Uint8Array): Uint8Array {
* Serializes a script by encoding its length as a varint and concatenating it with the script.
*
* @param s - The script to be serialized.
* @returns The serialized script as a Buffer.
* @returns The serialized script as a Uint8Array.
*/
function serializeScript(s: Uint8Array): Uint8Array {
/* global BigInt */
Expand Down
2 changes: 1 addition & 1 deletion ts_src/psbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ function getPrevoutTaprootKey(
cache: PsbtCache,
): Uint8Array | null {
const { script } = getScriptAndAmountFromUtxo(inputIndex, input, cache);
return isP2TR(script) ? script.subarray(2, 34) : null;
return isP2TR(script) ? script.slice(2, 34) : null;
}

function trimTaprootSig(signature: Uint8Array): Uint8Array {
Expand Down
2 changes: 1 addition & 1 deletion ts_src/psbt/bip371.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ function isTapLeafInTree(
*
* @param input - The PsbtInput object.
* @param tapLeaf - The TapLeafScript object.
* @returns An array of sorted signatures as Buffers.
* @returns An array of sorted signatures as Uint8Arrays.
*/
function sortSignatures(
input: PsbtInput,
Expand Down
2 changes: 1 addition & 1 deletion ts_src/psbt/psbtutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const isP2TR = isPaymentFactory(payments.p2tr);
/**
* Converts a witness stack to a script witness.
* @param witness The witness stack to convert.
* @returns The script witness as a Buffer.
* @returns The script witness as a Uint8Array.
*/
export function witnessStackToScriptWitness(witness: Uint8Array[]): Uint8Array {
let buffer = new Uint8Array(0);
Expand Down
4 changes: 2 additions & 2 deletions ts_src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ export function toASM(chunks: Uint8Array | Array<number | Uint8Array>): string {
}

/**
* Converts an ASM string to a Buffer.
* Converts an ASM string to a Uint8Array.
* @param asm The ASM string to convert.
* @returns The converted Buffer.
* @returns The converted Uint8Array.
*/
export function fromASM(asm: string): Uint8Array {
v.parse(v.string(), asm);
Expand Down
6 changes: 3 additions & 3 deletions ts_src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const NBufferSchemaFactory = (size: number) =>
v.pipe(v.instance(Uint8Array), v.length(size));

/**
* Checks if two arrays of Buffers are equal.
* @param a - The first array of Buffers.
* @param b - The second array of Buffers.
* Checks if two arrays of Uint8Arrays are equal.
* @param a - The first array of Uint8Arrays.
* @param b - The second array of Uint8Arrays.
* @returns True if the arrays are equal, false otherwise.
*/
export function stacksEqual(a: Uint8Array[], b: Uint8Array[]): boolean {
Expand Down