Skip to content

Commit 3c02879

Browse files
committed
chore: code clean-up; fix o.scriptLeaf (needs tests)
1 parent 26fbc03 commit 3c02879

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/payments/p2tr.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ const bech32_1 = require('bech32');
1111
const OPS = bscript.OPS;
1212
const TAPROOT_VERSION = 0x01;
1313
const ANNEX_PREFIX = 0x50;
14-
// witness: {signature}
15-
// input: <>
16-
// output: OP_1 {pubKey}
1714
function p2tr(a, opts) {
1815
if (
1916
!a.address &&
@@ -93,7 +90,7 @@ function p2tr(a, opts) {
9390
return bscript.compile([OPS.OP_1, o.pubkey]);
9491
});
9592
lazy.prop(o, 'scriptLeaf', () => {
96-
if (!a.scriptLeaf) return a.scriptLeaf;
93+
if (a.scriptLeaf) return a.scriptLeaf;
9794
});
9895
lazy.prop(o, 'pubkey', () => {
9996
if (a.pubkey) return a.pubkey;

ts_src/payments/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ import { p2tr } from './p2tr';
1212
export interface Payment {
1313
name?: string;
1414
network?: Network;
15-
output?: Buffer; // the full scriptPubKey
15+
output?: Buffer;
1616
data?: Buffer[];
1717
m?: number;
1818
n?: number;
1919
pubkeys?: Buffer[];
2020
input?: Buffer;
2121
signatures?: Buffer[];
22-
internalPubkey?: Buffer; // taproot: output key
23-
pubkey?: Buffer; // taproot: output key
22+
internalPubkey?: Buffer;
23+
pubkey?: Buffer;
2424
signature?: Buffer;
25-
address?: string; // taproot: betch32m
26-
hash?: Buffer; // taproot: MAST root
25+
address?: string;
26+
hash?: Buffer;
2727
redeem?: Payment;
2828
scriptsTree?: any; // todo: solve
2929
scriptLeaf?: TaprootLeaf;

ts_src/payments/p2tr.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ const OPS = bscript.OPS;
1818
const TAPROOT_VERSION = 0x01;
1919
const ANNEX_PREFIX = 0x50;
2020

21-
// witness: {signature}
22-
// input: <>
23-
// output: OP_1 {pubKey}
2421
export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
2522
if (
2623
!a.address &&
@@ -105,7 +102,7 @@ export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
105102
return bscript.compile([OPS.OP_1, o.pubkey]);
106103
});
107104
lazy.prop(o, 'scriptLeaf', () => {
108-
if (!a.scriptLeaf) return a.scriptLeaf;
105+
if (a.scriptLeaf) return a.scriptLeaf;
109106
});
110107
lazy.prop(o, 'pubkey', () => {
111108
if (a.pubkey) return a.pubkey;

0 commit comments

Comments
 (0)