MCPcopy Create free account
hub / github.com/NoteProtocol/NoteWallet / finalizeP2TRNoteInput

Function finalizeP2TRNoteInput

src/btc/btc-p2tr-note.ts:8–35  ·  view source on GitHub ↗
(
  psbt: bitcoin.Psbt,
  inputIndex: number,
  tapLeafNoteScript: TapLeafScript,
  notePayload: NotePayload
)

Source from the content-addressed store, hash-verified

6import {witnessStackToScriptWitness} from "./witness_stack_to_script_witness";
7
8export 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.

Callers 2

createP2TRNotePsbtV1Function · 0.90
createP2TRNotePsbtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected