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` throughout (Node `Buffer` remains compatible), and
- Friendly, with a strong and helpful community, ready to answer questions.

## Documentation
Expand Down
4 changes: 2 additions & 2 deletions src/cjs/address.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function toBech32(data, version, prefix) {
}
/**
* Converts an output script to a Bitcoin address.
* @param output - The output script as a Buffer.
* @param output - The output script as a Uint8Array.
* @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 @@ function fromOutputScript(output, network) {
* 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.
*/
function toOutputScript(address, network) {
Expand Down
4 changes: 2 additions & 2 deletions src/cjs/address.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export declare function toBase58Check(hash: Uint8Array, version: number): string
export declare function toBech32(data: Uint8Array, version: number, prefix: string): string;
/**
* Converts an output script to a Bitcoin address.
* @param output - The output script as a Buffer.
* @param output - The output script as a Uint8Array.
* @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 All @@ -66,7 +66,7 @@ export declare function fromOutputScript(output: Uint8Array, network?: Network):
* 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 declare function toOutputScript(address: string, network?: Network): Uint8Array;
4 changes: 2 additions & 2 deletions src/cjs/payments/bip341.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function findScriptPath(node, hash) {
/**
* 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.
*/
function tapleafHash(leaf) {
const version = leaf.version || exports.LEAF_VERSION_TAPSCRIPT;
Expand Down Expand Up @@ -181,7 +181,7 @@ function tapBranchHash(a, b) {
* 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) {
/* global BigInt */
Expand Down
2 changes: 1 addition & 1 deletion src/cjs/payments/bip341.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export declare function findScriptPath(node: HashTree, hash: Uint8Array): Uint8A
/**
* 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 declare function tapleafHash(leaf: Tapleaf): Uint8Array;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/cjs/psbt.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ const DEFAULT_OPTS = {
* `psbt.addOutput(output)`, `psbt.addOutputs(outputs)` when you are looking to
* add new inputs and outputs to the PSBT, and `psbt.updateGlobal(itemObject)`,
* `psbt.updateInput(itemObject)`, `psbt.updateOutput(itemObject)`
* addInput requires hash: Buffer | string; and index: number; as attributes
* addInput requires hash: Uint8Array | string; and index: number; as attributes
* and can also include any attributes that are used in updateInput method.
* addOutput requires script: Buffer; and value: number; and likewise can include
* addOutput requires script: Uint8Array; and value: number; and likewise can include
* data for updateOutput.
* For a list of what attributes should be what types. Check the bip174 library.
* Also, check the integration tests for some examples of usage.
Expand Down
4 changes: 2 additions & 2 deletions src/cjs/psbt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export type ValidateSigFunction = (pubkey: Uint8Array, msghash: Uint8Array, sign
* `psbt.addOutput(output)`, `psbt.addOutputs(outputs)` when you are looking to
* add new inputs and outputs to the PSBT, and `psbt.updateGlobal(itemObject)`,
* `psbt.updateInput(itemObject)`, `psbt.updateOutput(itemObject)`
* addInput requires hash: Buffer | string; and index: number; as attributes
* addInput requires hash: Uint8Array | string; and index: number; as attributes
* and can also include any attributes that are used in updateInput method.
* addOutput requires script: Buffer; and value: number; and likewise can include
* addOutput requires script: Uint8Array; and value: number; and likewise can include
* data for updateOutput.
* For a list of what attributes should be what types. Check the bip174 library.
* Also, check the integration tests for some examples of usage.
Expand Down
2 changes: 1 addition & 1 deletion src/cjs/psbt/psbtutils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ exports.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.
*/
function witnessStackToScriptWitness(witness) {
let buffer = new Uint8Array(0);
Expand Down
2 changes: 1 addition & 1 deletion src/cjs/psbt/psbtutils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export declare const isP2TR: (script: Uint8Array) => boolean;
/**
* 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 declare function witnessStackToScriptWitness(witness: Uint8Array[]): Uint8Array;
/**
Expand Down
6 changes: 3 additions & 3 deletions src/cjs/script.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function decompile(buffer) {
}
/**
* Converts the given chunks into an ASM (Assembly) string representation.
* If the chunks parameter is a Buffer, it will be decompiled into a Stack before conversion.
* If the chunks parameter is a Uint8Array (Buffer-compatible), it will be decompiled into a Stack before conversion.
* @param chunks - The chunks to convert into ASM.
* @returns The ASM string representation of the chunks.
*/
Expand All @@ -265,9 +265,9 @@ function toASM(chunks) {
.join(' ');
}
/**
* 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.
*/
function fromASM(asm) {
v.parse(v.string(), asm);
Expand Down
6 changes: 3 additions & 3 deletions src/cjs/script.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export declare function compile(chunks: Uint8Array | Stack): Uint8Array;
export declare function decompile(buffer: Uint8Array | Array<number | Uint8Array>): Array<number | Uint8Array> | null;
/**
* Converts the given chunks into an ASM (Assembly) string representation.
* If the chunks parameter is a Buffer, it will be decompiled into a Stack before conversion.
* If the chunks parameter is a Uint8Array (Buffer-compatible), it will be decompiled into a Stack before conversion.
* @param chunks - The chunks to convert into ASM.
* @returns The ASM string representation of the chunks.
*/
export declare 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 declare function fromASM(asm: string): Uint8Array;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/esm/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function toBech32(data, version, prefix) {
}
/**
* Converts an output script to a Bitcoin address.
* @param output - The output script as a Buffer.
* @param output - The output script as a Uint8Array.
* @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 @@ -149,7 +149,7 @@ export function fromOutputScript(output, network) {
* 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, network) {
Expand Down
4 changes: 2 additions & 2 deletions src/esm/payments/bip341.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function findScriptPath(node, hash) {
/**
* 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) {
const version = leaf.version || LEAF_VERSION_TAPSCRIPT;
Expand Down Expand Up @@ -124,7 +124,7 @@ function tapBranchHash(a, b) {
* 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) {
/* global BigInt */
Expand Down
4 changes: 2 additions & 2 deletions src/esm/psbt.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ const DEFAULT_OPTS = {
* `psbt.addOutput(output)`, `psbt.addOutputs(outputs)` when you are looking to
* add new inputs and outputs to the PSBT, and `psbt.updateGlobal(itemObject)`,
* `psbt.updateInput(itemObject)`, `psbt.updateOutput(itemObject)`
* addInput requires hash: Buffer | string; and index: number; as attributes
* addInput requires hash: Uint8Array | string; and index: number; as attributes
* and can also include any attributes that are used in updateInput method.
* addOutput requires script: Buffer; and value: number; and likewise can include
* addOutput requires script: Uint8Array; and value: number; and likewise can include
* data for updateOutput.
* For a list of what attributes should be what types. Check the bip174 library.
* Also, check the integration tests for some examples of usage.
Expand Down
2 changes: 1 addition & 1 deletion src/esm/psbt/psbtutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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) {
let buffer = new Uint8Array(0);
Expand Down
6 changes: 3 additions & 3 deletions src/esm/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function decompile(buffer) {
}
/**
* Converts the given chunks into an ASM (Assembly) string representation.
* If the chunks parameter is a Buffer, it will be decompiled into a Stack before conversion.
* If the chunks parameter is a Uint8Array (Buffer-compatible), it will be decompiled into a Stack before conversion.
* @param chunks - The chunks to convert into ASM.
* @returns The ASM string representation of the chunks.
*/
Expand All @@ -203,9 +203,9 @@ export function toASM(chunks) {
.join(' ');
}
/**
* 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) {
v.parse(v.string(), asm);
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.
* @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
4 changes: 2 additions & 2 deletions ts_src/psbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ const DEFAULT_OPTS: PsbtOpts = {
* `psbt.addOutput(output)`, `psbt.addOutputs(outputs)` when you are looking to
* add new inputs and outputs to the PSBT, and `psbt.updateGlobal(itemObject)`,
* `psbt.updateInput(itemObject)`, `psbt.updateOutput(itemObject)`
* addInput requires hash: Buffer | string; and index: number; as attributes
* addInput requires hash: Uint8Array | string; and index: number; as attributes
* and can also include any attributes that are used in updateInput method.
* addOutput requires script: Buffer; and value: number; and likewise can include
* addOutput requires script: Uint8Array; and value: number; and likewise can include
* data for updateOutput.
* For a list of what attributes should be what types. Check the bip174 library.
* Also, check the integration tests for some examples of usage.
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
6 changes: 3 additions & 3 deletions ts_src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export function decompile(

/**
* Converts the given chunks into an ASM (Assembly) string representation.
* If the chunks parameter is a Buffer, it will be decompiled into a Stack before conversion.
* If the chunks parameter is a Uint8Array (Buffer-compatible), it will be decompiled into a Stack before conversion.
* @param chunks - The chunks to convert into ASM.
* @returns The ASM string representation of the chunks.
*/
Expand All @@ -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
Loading