MCPcopy Create free account
hub / github.com/CashScript/cashscript / getTxSizeWithoutInputs

Function getTxSizeWithoutInputs

packages/cashscript/src/utils.ts:209–231  ·  view source on GitHub ↗
(outputs: Output[])

Source from the content-addressed store, hash-verified

207}
208
209export function getTxSizeWithoutInputs(outputs: Output[]): number {
210 // Transaction format:
211 // Version (4 Bytes)
212 // TxIn Count (1 ~ 9B)
213 // For each TxIn:
214 // Outpoint (36B)
215 // Script Length (1 ~ 9B)
216 // ScriptSig(?)
217 // Sequence (4B)
218 // TxOut Count (1 ~ 9B)
219 // For each TxOut:
220 // Value (8B)
221 // Script Length(1 ~ 9B)*
222 // Script (?)*
223 // LockTime (4B)
224
225 let size = VERSION_SIZE + LOCKTIME_SIZE;
226 size += outputs.reduce((acc, output) => acc + getOutputSize(output), 0);
227 // Add tx-out count (accounting for a potential change output)
228 size += bigIntToCompactUint(BigInt(outputs.length + 1)).byteLength;
229
230 return size;
231}
232
233// ////////// BUILD OBJECTS ///////////////////////////////////////////////////
234export function createUnlockingBytecode(

Callers

nothing calls this directly

Calls 1

getOutputSizeFunction · 0.85

Tested by

no test coverage detected