@@ -8,7 +8,6 @@ import { bech32m } from 'bech32';
88// Explicitly import the Payment type for clarity
99import { Payment , PaymentOpts } from './index' ;
1010import * as lazy from './lazy' ;
11- import * as payments from './index.ts' ;
1211import { taggedHash } from '../crypto' ;
1312import { Input } from '../transaction' ;
1413
@@ -90,12 +89,11 @@ export const findSmallestOutpoint = (inputs: Array<Input>) =>
9089 * @param vout - output index
9190 * @returns the serialized little endian encoded output
9291 */
93- export const serOutpointLE = ( txidHexBE : string , vout : number ) => {
92+ export const serOutpointLE = ( txidHexBE : Uint8Array , vout : number ) => {
9493 const out = new Uint8Array ( 36 ) ;
95- const txidLE = tools . fromHex ( txidHexBE ) ;
96- if ( txidLE . length !== 32 ) throw new Error ( 'txid must be 32 bytes' ) ;
97- txidLE . reverse ( ) ; // BE -> LE
98- out . set ( txidLE , 0 ) ;
94+ if ( txidHexBE . length !== 32 ) throw new Error ( 'txid must be 32 bytes' ) ;
95+ txidHexBE . reverse ( ) ; // BE -> LE
96+ out . set ( txidHexBE , 0 ) ;
9997 writeUInt32 ( out , 32 , vout >>> 0 , 'le' ) ;
10098 return out ;
10199} ;
@@ -395,9 +393,10 @@ export function deriveOutput(
395393 S : Uint8Array ,
396394 spendPubkey : Uint8Array ,
397395 k : number ,
398- ) : { pub_key : Uint8Array ; tweak_key } {
396+ ) : { pub_key : Uint8Array ; tweak_key : Uint8Array } {
399397 // t_k = H_tag(SharedSecret, ser_P(S) || ser32BE(k)) -> reduce mod n
400398 const t_k : Uint8Array < ArrayBufferLike > | null = calculateT_k ( S , k ) ;
399+ if ( ! t_k ) throw new Error ( 't_k: failed' ) ;
401400
402401 // P_k = B_spend + t_k·G (compressed) -> x-only for P2TR
403402 const P_k : Uint8Array < ArrayBufferLike > = calculateP_k ( spendPubkey , t_k ) ;
@@ -453,7 +452,6 @@ export function generateLabelAndAddress(
453452 * Scans a transaction's inputs and outputs to find any silent payments for the receiver.
454453 * @param receiverScanPrivkey - b_scan
455454 * @param receiverSpendPrivkey - b_spend
456- * @param smallestOutpoint
457455 * @param inputHashTweak
458456 * @param summedSenderPubkey - A_sum
459457 * @param outputsToCheck - array of hex xOnly encoded outputs to check
@@ -462,20 +460,19 @@ export function generateLabelAndAddress(
462460export function scanForSilentPayments (
463461 receiverScanPrivkey : Uint8Array ,
464462 receiverSpendPrivkey : Uint8Array ,
465- smallestOutpoint : Uint8Array ,
466463 inputHashTweak : Uint8Array ,
467464 summedSenderPubkey : Uint8Array ,
468465 outputsToCheck : Set < string > ,
469- labelNonces : Array < Uint8Array > = Array . from ( [ ] ) ,
466+ labelNonces : Array < number > = Array . from ( [ ] ) ,
470467) : {
471468 priv_key_tweak : Uint8Array ;
472469 pub_key : Uint8Array ;
473- labelNonce ?: Uint8Array ;
470+ labelNonce ?: number ;
474471} [ ] {
475472 let foundPayments : {
476473 priv_key_tweak : Uint8Array ;
477474 pub_key : Uint8Array ;
478- labelNonce ?: Uint8Array ;
475+ labelNonce ?: number ;
479476 } [ ] = [ ] ;
480477
481478 // G
@@ -529,7 +526,7 @@ function performScan(
529526 outputsToCheck : Set < string > ,
530527 labelScalar : Uint8Array | null , // L (or null for base)
531528) : { priv_key_tweak : Uint8Array ; pub_key : Uint8Array } [ ] {
532- const found : { payment : Payment ; t : Uint8Array ; P_xonly : Uint8Array } [ ] = [ ] ;
529+ const found : { priv_key_tweak : Uint8Array ; pub_key : Uint8Array } [ ] = [ ] ;
533530
534531 for ( let k = 0 ; k < outputsToCheck . size ; k ++ ) {
535532 const derivedOutput = deriveOutput ( S , receiverSpendPubkey , k ) ;
0 commit comments