nl_tokens: / * Serializes a TXOBJ into hex string
pl_tokens: function serializeTx ( txObj ) { var serializedTx = '' ; var _buf16 = Buffer . alloc ( 4 ) ; // Version _buf16 . writeUInt16LE ( txObj . version , 0 ) ; serializedTx += _buf16 . toString ( 'hex' ) ; // History serializedTx += zbufferutils . numToVarInt ( txObj . ins . length ) ; txObj . ins . map ( function ( i ) { // Txids and vouts _buf16 . writeUInt16LE ( i . output . vout , 0 ) ; serializedTx += Buffer . from ( i . output . hash , 'hex' ) . reverse ( ) . toString ( 'hex' ) ; serializedTx += _buf16 . toString ( 'hex' ) ; // Script Signature // Doesn't work for length > 253 .... serializedTx += zbufferutils . getPushDataLength ( i . script ) ; serializedTx += i . script ; // Sequence serializedTx += i . sequence ; } ) ; // Outputs serializedTx += zbufferutils . numToVarInt ( txObj . outs . length ) ; txObj . outs . map ( function ( o ) { // Write 64bit buffers // JS only supports 56 bit // https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/bufferutils.js#L25 var _buf32 = Buffer . alloc ( 8 ) ; // Satohis _buf32 . writeInt32LE ( o . satoshis & - 1 , 0 ) ; _buf32 . writeUInt32LE ( Math . <mask> ( o . satoshis / 0x100000000 ) , 4 ) ; // ScriptPubKey serializedTx += _buf32 . toString ( 'hex' ) ; serializedTx += zbufferutils . getPushDataLength ( o . script ) ; serializedTx += o . script ; } ) ; // Locktime _buf16 . writeUInt16LE ( txObj . locktime , 0 ) ; serializedTx += _buf16 . toString ( 'hex' ) ; return serializedTx ; }