nl_tokens: / * Gets signature for the vin script
pl_tokens: function getScriptSignature ( privKey , signingTx , hashcode ) { // Buffer var _buf16 = Buffer . alloc ( 4 ) ; _buf16 . writeUInt16LE ( hashcode , 0 ) ; var signingTxHex = serializeTx ( signingTx ) ; var signingTxWithHashcode = signingTxHex + _buf16 . toString ( 'hex' ) ; // Sha256 it twice, according to spec var msg = zcrypto . sha256x2 ( <mask> . from ( signingTxWithHashcode , 'hex' ) ) ; // Signing it var rawsig = secp256k1 . sign ( Buffer . from ( msg , 'hex' ) , Buffer . from ( privKey , 'hex' ) , { canonical : true } ) ; // Convert it to DER format // Appending 01 to it cause // ScriptSig = <varint of total sig length> <SIG from code, including appended 01 SIGNHASH> <length of pubkey (0x21 or 0x41)> <pubkey> // https://bitcoin.stackexchange.com/a/36481 var signatureDER = Buffer . from ( rawsig . toDER ( ) ) . toString ( 'hex' ) + '01' ; return signatureDER ; }