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

Function addChangeOutput

src/btc/btc-p2tr-note.ts:178–194  ·  view source on GitHub ↗
(
  psbt: bitcoin.Psbt,
  totalInput: number,
  totalOutput: number,
  fee: number,
  change: string
)

Source from the content-addressed store, hash-verified

176
177//添加找零输出
178function addChangeOutput(
179 psbt: bitcoin.Psbt,
180 totalInput: number,
181 totalOutput: number,
182 fee: number,
183 change: string
184) {
185 const value = totalInput - totalOutput - fee;
186 if (value < 0) throw new Error("NoFund");
187 // If value is greater than the minimum change, add a change output, otherwise don't add
188 if (value > MIN_SATOSHIS) {
189 psbt.addOutput({
190 address: change,
191 value: Number(value),
192 });
193 }
194}
195
196function signInputs(
197 psbt: bitcoin.Psbt,

Callers 1

createP2TRNotePsbtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected