// src/utils/transactionUtils.jsimport { PrivateKey, PublicKey, Transaction, BigNumber, Hash, Point, P2PKH } from'@bsv/sdk';// Function to hash ticket informationconsthashTicket= (ticketInfo:string) => {returnHash.sha256(ticketInfo);};// Function to add a hash to a public keyconstaddHashToPublicKey= (pubKey:PublicKey, hash:BigNumber) => {constpubKeyHash=Hash.sha256(pubKey.toDER());consthashNum=newBigNumber(pubKeyHash,16);constcurrentPoint= pubKey;constnewX=currentPoint.getX().add(hashNum).umod(pubKey.curve.p);constnewY=currentPoint.getY();constnewPoint=newPoint(newX, newY,newY.isEven());returnnewPublicKey(newPoint);};// Function to create a tranche transactionexportconstcreateTrancheTransaction=async (tickets:string[]) => {constprivateKey=PrivateKey.fromRandom();constpublicKey=privateKey.toPublicKey();consttransaction=tickets.map((ticket) => {constticketHash=hashTicket(ticket);constnewPubKey=addHashToPublicKey(publicKey,newBigNumber(ticketHash));constlockingScript=newP2PKH().lock(newPubKey.toAddress());consttx=newTransaction();tx.addOutput({ lockingScript: lockingScript, satoshis:1000,// Example value, adjust as needed });return tx; });return transaction;};