Skip to content

Commit 37b0f1c

Browse files
committed
Consistent capitalization of tapleaf
1 parent 47f3158 commit 37b0f1c

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/payments/p2tr.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function p2tr(a, opts) {
8989
const controlBlock = w[w.length - 1];
9090
const leafVersion = controlBlock[0] & types_1.TAPLEAF_VERSION_MASK;
9191
const script = w[w.length - 2];
92-
const leafHash = (0, taprootutils_1.tapLeafHash)({
92+
const leafHash = (0, taprootutils_1.tapleafHash)({
9393
output: script,
9494
version: leafVersion,
9595
});
@@ -147,7 +147,7 @@ function p2tr(a, opts) {
147147
if (a.scriptTree && a.redeem && a.redeem.output && a.internalPubkey) {
148148
// todo: optimize/cache
149149
const hashTree = (0, taprootutils_1.toHashTree)(a.scriptTree);
150-
const leafHash = (0, taprootutils_1.tapLeafHash)({
150+
const leafHash = (0, taprootutils_1.tapleafHash)({
151151
output: a.redeem.output,
152152
version: o.redeemVersion,
153153
});
@@ -258,7 +258,7 @@ function p2tr(a, opts) {
258258
throw new TypeError('Invalid internalPubkey for p2tr witness');
259259
const leafVersion = controlBlock[0] & types_1.TAPLEAF_VERSION_MASK;
260260
const script = witness[witness.length - 2];
261-
const leafHash = (0, taprootutils_1.tapLeafHash)({
261+
const leafHash = (0, taprootutils_1.tapleafHash)({
262262
output: script,
263263
version: leafVersion,
264264
});

src/payments/taprootutils.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference types="node" />
22
import { Tapleaf, Taptree } from '../types';
33
export declare const LEAF_VERSION_TAPSCRIPT = 192;
4-
export declare function rootHashFromPath(controlBlock: Buffer, tapLeafMsg: Buffer): Buffer;
4+
export declare function rootHashFromPath(controlBlock: Buffer, tapleafMsg: Buffer): Buffer;
55
export interface HashTree {
66
hash: Buffer;
77
left?: HashTree;
@@ -23,5 +23,5 @@ export declare function toHashTree(scriptTree: Taptree): HashTree;
2323
* @returns - and array of hashes representing the path, or an empty array if no pat is found
2424
*/
2525
export declare function findScriptPath(node: HashTree, hash: Buffer): Buffer[];
26-
export declare function tapLeafHash(leaf: Tapleaf): Buffer;
26+
export declare function tapleafHash(leaf: Tapleaf): Buffer;
2727
export declare function tapTweakHash(pubKey: Buffer, h: Buffer | undefined): Buffer;

src/payments/taprootutils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
Object.defineProperty(exports, '__esModule', { value: true });
3-
exports.tapTweakHash = exports.tapLeafHash = exports.findScriptPath = exports.toHashTree = exports.rootHashFromPath = exports.LEAF_VERSION_TAPSCRIPT = void 0;
3+
exports.tapTweakHash = exports.tapleafHash = exports.findScriptPath = exports.toHashTree = exports.rootHashFromPath = exports.LEAF_VERSION_TAPSCRIPT = void 0;
44
const buffer_1 = require('buffer');
55
const bcrypto = require('../crypto');
66
const bufferutils_1 = require('../bufferutils');
@@ -9,8 +9,8 @@ const TAP_LEAF_TAG = 'TapLeaf';
99
const TAP_BRANCH_TAG = 'TapBranch';
1010
const TAP_TWEAK_TAG = 'TapTweak';
1111
exports.LEAF_VERSION_TAPSCRIPT = 0xc0;
12-
function rootHashFromPath(controlBlock, tapLeafMsg) {
13-
const k = [tapLeafMsg];
12+
function rootHashFromPath(controlBlock, tapleafMsg) {
13+
const k = [tapleafMsg];
1414
const e = [];
1515
const m = (controlBlock.length - 33) / 32;
1616
for (let j = 0; j < m; j++) {
@@ -34,7 +34,7 @@ exports.rootHashFromPath = rootHashFromPath;
3434
*/
3535
function toHashTree(scriptTree) {
3636
if ((0, types_1.isTapleaf)(scriptTree))
37-
return { hash: tapLeafHash(scriptTree) };
37+
return { hash: tapleafHash(scriptTree) };
3838
const hashes = [toHashTree(scriptTree[0]), toHashTree(scriptTree[1])];
3939
hashes.sort((a, b) => a.hash.compare(b.hash));
4040
const [left, right] = hashes;
@@ -67,7 +67,7 @@ function findScriptPath(node, hash) {
6767
return [];
6868
}
6969
exports.findScriptPath = findScriptPath;
70-
function tapLeafHash(leaf) {
70+
function tapleafHash(leaf) {
7171
const version = leaf.version || exports.LEAF_VERSION_TAPSCRIPT;
7272
return bcrypto.taggedHash(
7373
TAP_LEAF_TAG,
@@ -77,7 +77,7 @@ function tapLeafHash(leaf) {
7777
]),
7878
);
7979
}
80-
exports.tapLeafHash = tapLeafHash;
80+
exports.tapleafHash = tapleafHash;
8181
function tapTweakHash(pubKey, h) {
8282
return bcrypto.taggedHash(
8383
TAP_TWEAK_TAG,

src/psbt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ function getHashForSig(
10791079
const signingScripts = prevOuts.map(o => o.script);
10801080
const values = prevOuts.map(o => o.value);
10811081
const leafHash = input.witnessScript
1082-
? (0, taprootutils_1.tapLeafHash)({ output: input.witnessScript })
1082+
? (0, taprootutils_1.tapleafHash)({ output: input.witnessScript })
10831083
: undefined;
10841084
hash = unsignedTx.hashForWitnessV1(
10851085
inputIndex,

ts_src/payments/p2tr.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
toHashTree,
1212
rootHashFromPath,
1313
findScriptPath,
14-
tapLeafHash,
14+
tapleafHash,
1515
tapTweakHash,
1616
LEAF_VERSION_TAPSCRIPT,
1717
} from './taprootutils';
@@ -107,7 +107,7 @@ export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
107107
const controlBlock = w[w.length - 1];
108108
const leafVersion = controlBlock[0] & TAPLEAF_VERSION_MASK;
109109
const script = w[w.length - 2];
110-
const leafHash = tapLeafHash({ output: script, version: leafVersion });
110+
const leafHash = tapleafHash({ output: script, version: leafVersion });
111111
return rootHashFromPath(controlBlock, leafHash);
112112
}
113113
return null;
@@ -164,7 +164,7 @@ export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
164164
if (a.scriptTree && a.redeem && a.redeem.output && a.internalPubkey) {
165165
// todo: optimize/cache
166166
const hashTree = toHashTree(a.scriptTree);
167-
const leafHash = tapLeafHash({
167+
const leafHash = tapleafHash({
168168
output: a.redeem.output,
169169
version: o.redeemVersion,
170170
});
@@ -292,7 +292,7 @@ export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
292292
const leafVersion = controlBlock[0] & TAPLEAF_VERSION_MASK;
293293
const script = witness[witness.length - 2];
294294

295-
const leafHash = tapLeafHash({ output: script, version: leafVersion });
295+
const leafHash = tapleafHash({ output: script, version: leafVersion });
296296
const hash = rootHashFromPath(controlBlock, leafHash);
297297

298298
const outputKey = tweakKey(internalPubkey, hash, _ecc());

ts_src/payments/taprootutils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export const LEAF_VERSION_TAPSCRIPT = 0xc0;
1212

1313
export function rootHashFromPath(
1414
controlBlock: Buffer,
15-
tapLeafMsg: Buffer,
15+
tapleafMsg: Buffer,
1616
): Buffer {
17-
const k = [tapLeafMsg];
17+
const k = [tapleafMsg];
1818
const e = [];
1919

2020
const m = (controlBlock.length - 33) / 32;
@@ -46,7 +46,7 @@ export interface HashTree {
4646
* - one taproot leaf and a list of elements
4747
*/
4848
export function toHashTree(scriptTree: Taptree): HashTree {
49-
if (isTapleaf(scriptTree)) return { hash: tapLeafHash(scriptTree) };
49+
if (isTapleaf(scriptTree)) return { hash: tapleafHash(scriptTree) };
5050

5151
const hashes = [toHashTree(scriptTree[0]), toHashTree(scriptTree[1])];
5252
hashes.sort((a, b) => a.hash.compare(b.hash));
@@ -83,7 +83,7 @@ export function findScriptPath(node: HashTree, hash: Buffer): Buffer[] {
8383
return [];
8484
}
8585

86-
export function tapLeafHash(leaf: Tapleaf): Buffer {
86+
export function tapleafHash(leaf: Tapleaf): Buffer {
8787
const version = leaf.version || LEAF_VERSION_TAPSCRIPT;
8888
return bcrypto.taggedHash(
8989
TAP_LEAF_TAG,

ts_src/psbt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { bitcoin as btcNetwork, Network } from './networks';
2121
import * as payments from './payments';
2222
import * as bscript from './script';
2323
import { Output, Transaction } from './transaction';
24-
import { tapLeafHash } from './payments/taprootutils';
24+
import { tapleafHash } from './payments/taprootutils';
2525
import { TinySecp256k1Interface } from './types';
2626

2727
export interface TransactionInput {
@@ -1406,7 +1406,7 @@ function getHashForSig(
14061406
const signingScripts: any = prevOuts.map(o => o.script);
14071407
const values: any = prevOuts.map(o => o.value);
14081408
const leafHash = input.witnessScript
1409-
? tapLeafHash({ output: input.witnessScript })
1409+
? tapleafHash({ output: input.witnessScript })
14101410
: undefined;
14111411

14121412
hash = unsignedTx.hashForWitnessV1(

0 commit comments

Comments
 (0)