( psbt: bitcoin.Psbt, inputIndex: number, tapLeafNoteScript: TapLeafScript, notePayload: NotePayload )
| 6 | import {witnessStackToScriptWitness} from "./witness_stack_to_script_witness"; |
| 7 | |
| 8 | export function finalizeP2TRNoteInput( |
| 9 | psbt: bitcoin.Psbt, |
| 10 | inputIndex: number, |
| 11 | tapLeafNoteScript: TapLeafScript, |
| 12 | notePayload: NotePayload |
| 13 | ) { |
| 14 | function getNoteFinalScripts(index: number, input: any) { |
| 15 | const scriptSolution = [ |
| 16 | input.tapScriptSig[0].signature, |
| 17 | Buffer.from(notePayload.data0, "hex"), |
| 18 | Buffer.from(notePayload.data1, "hex"), |
| 19 | Buffer.from(notePayload.data2, "hex"), |
| 20 | Buffer.from(notePayload.data3, "hex"), |
| 21 | Buffer.from(notePayload.data4, "hex"), |
| 22 | ]; |
| 23 | const witness = scriptSolution |
| 24 | .concat(tapLeafNoteScript.script) |
| 25 | .concat(tapLeafNoteScript.controlBlock); |
| 26 | |
| 27 | const finalScriptWitness = witnessStackToScriptWitness(witness); |
| 28 | |
| 29 | return { |
| 30 | finalScriptWitness, |
| 31 | }; |
| 32 | } |
| 33 | |
| 34 | psbt.finalizeInput(inputIndex, getNoteFinalScripts); |
| 35 | } |
| 36 | /** |
| 37 | * The function `createP2TRNotePsbt` generates a P2TR transaction with a NOTE payload as the first |
| 38 | * input and account notifications as outputs, handling inputs, outputs, fees, and signing processes. |
no outgoing calls
no test coverage detected