os.environ["NODE_PATH"] = r"C:\Users\PlanPoint\node_modules"
print(os.environ["NODE_PATH"])
print(execjs.get().name)
parser = execjs.compile("""
var liteCore = require('litecore-lib');
function parse(text) {
var privateKey = new liteCore.PrivateKey(text);
var publicKey = privateKey.toPublicKey();
var address = privateKey.toAddress();
var address2 = publicKey.toAddress(liteCore.Networks.testnet);
var toaddr = "n1F3e7b4C5VbaCBksoyBeLdJT2iB7TCAcr"
var utxos = '[{"address":"n4G7vt2ANN5rHz6c4V3dz7DyxG7qbwsi4r","txid":"e168527db3b34ca0f93c2dbbb08c9cdd09b150d333af30b18b54ac6442209789","vout":1,"scriptPubKey":"76a914f97cb24a04c278fb944cdefdec37c302838baca888ac","amount":1,"satoshis":100000000,"height":712547,"confirmations":11},{"address":"n4G7vt2ANN5rHz6c4V3dz7DyxG7qbwsi4r","txid":"8c3010b16f0b732f31cb76ab6f9d0b43b69f4ac6c5a3b54018ea28290cf80041","vout":0,"scriptPubKey":"76a914f97cb24a04c278fb944cdefdec37c302838baca888ac","amount":3,"satoshis":300000000,"height":712547,"confirmations":11}]'
var transaction = new liteCore.Transaction()
.from(utxos)
.to(toaddr, 200000000)
.change(address2)
.sign(privateKey)
.serialize();
return transaction;
}
""")
if name == "main":
obj = parser.call("parse", 'e735a14ef488a42d5621e8f75b53eddd3cbbb505557945cd07df65bb2dd78dd0')
print(obj)
and error message is: E:\zt_6.27\python\python.exe E:/zt_6.27/py2/testLTC2.py
C:\Users\PlanPoint\node_modules
Node.js (V8)
Traceback (most recent call last):
File "E:/zt_6.27/py2/testLTC2.py", line 26, in
obj = parser.call("parse", 'e735a14ef488a42d5621e8f75b53eddd3cbbb505557945cd07df65bb2dd78dd0')
File "E:\zt_6.27\python\lib\site-packages\execjs_abstract_runtime_context.py", line 37, in call
return self._call(name, *args)
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 92, in _call
return self._eval("{identifier}.apply(this, {args})".format(identifier=identifier, args=args))
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 78, in eval
return self.exec(code)
File "E:\zt_6.27\python\lib\site-packages\execjs_abstract_runtimecontext.py", line 18, in exec
return self.exec(source)
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 88, in exec
return self._extract_result(output)
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 167, in _extract_result
raise ProgramError(value)
execjs._exceptions.ProgramError: litecore.ErrorInvalidArgument: Invalid Argument: Must provide an object from where to extract data
This is my code: `import execjs import os
os.environ["NODE_PATH"] = r"C:\Users\PlanPoint\node_modules" print(os.environ["NODE_PATH"]) print(execjs.get().name) parser = execjs.compile(""" var liteCore = require('litecore-lib'); function parse(text) { var privateKey = new liteCore.PrivateKey(text); var publicKey = privateKey.toPublicKey(); var address = privateKey.toAddress(); var address2 = publicKey.toAddress(liteCore.Networks.testnet); var toaddr = "n1F3e7b4C5VbaCBksoyBeLdJT2iB7TCAcr" var utxos = '[{"address":"n4G7vt2ANN5rHz6c4V3dz7DyxG7qbwsi4r","txid":"e168527db3b34ca0f93c2dbbb08c9cdd09b150d333af30b18b54ac6442209789","vout":1,"scriptPubKey":"76a914f97cb24a04c278fb944cdefdec37c302838baca888ac","amount":1,"satoshis":100000000,"height":712547,"confirmations":11},{"address":"n4G7vt2ANN5rHz6c4V3dz7DyxG7qbwsi4r","txid":"8c3010b16f0b732f31cb76ab6f9d0b43b69f4ac6c5a3b54018ea28290cf80041","vout":0,"scriptPubKey":"76a914f97cb24a04c278fb944cdefdec37c302838baca888ac","amount":3,"satoshis":300000000,"height":712547,"confirmations":11}]' var transaction = new liteCore.Transaction() .from(utxos) .to(toaddr, 200000000) .change(address2) .sign(privateKey) .serialize(); return transaction; } """) if name == "main": obj = parser.call("parse", 'e735a14ef488a42d5621e8f75b53eddd3cbbb505557945cd07df65bb2dd78dd0') print(obj)
obj = parser.call("parse", 'e735a14ef488a42d5621e8f75b53eddd3cbbb505557945cd07df65bb2dd78dd0')
File "E:\zt_6.27\python\lib\site-packages\execjs_abstract_runtime_context.py", line 37, in call
return self._call(name, *args)
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 92, in _call
return self._eval("{identifier}.apply(this, {args})".format(identifier=identifier, args=args))
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 78, in eval
return self.exec(code)
File "E:\zt_6.27\python\lib\site-packages\execjs_abstract_runtimecontext.py", line 18, in exec
return self.exec(source)
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 88, in exec
return self._extract_result(output)
File "E:\zt_6.27\python\lib\site-packages\execjs_external_runtime.py", line 167, in _extract_result
raise ProgramError(value)
execjs._exceptions.ProgramError: litecore.ErrorInvalidArgument: Invalid Argument: Must provide an object from where to extract data
and error message is:
E:\zt_6.27\python\python.exe E:/zt_6.27/py2/testLTC2.py C:\Users\PlanPoint\node_modules Node.js (V8) Traceback (most recent call last): File "E:/zt_6.27/py2/testLTC2.py", line 26, inProcess finished with exit code 1`
What caused it? I wrote according to the guide.