From 37d73fd426d9fbd72edfe0c4213a580542985050 Mon Sep 17 00:00:00 2001 From: ethers Date: Mon, 14 Jul 2014 02:27:46 -0700 Subject: [PATCH] small ScriptInterpreter example --- examples/ScriptInterpreter.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/ScriptInterpreter.js diff --git a/examples/ScriptInterpreter.js b/examples/ScriptInterpreter.js new file mode 100644 index 000000000..039710c98 --- /dev/null +++ b/examples/ScriptInterpreter.js @@ -0,0 +1,28 @@ +'use strict'; + +var run = function() { + // Replace '../bitcore' with 'bitcore' if you use this code elsewhere. + var bitcore = require('../bitcore'); + var Address = bitcore.Address; + var coinUtil = bitcore.util; + var Script = bitcore.Script; + var ScriptInterpreter = bitcore.ScriptInterpreter; + var network = bitcore.networks.testnet; + + + var scriptPubKeyHR = '0x14 0x3744841e13b90b4aca16fe793a7f88da3a23cc71 EQUAL'; + var scriptPubKey = Script.fromHumanReadable(scriptPubKeyHR); + + var scriptSigHR = '0x14 0x3744841e13b90b4aca16fe793a7f88da3a23cc71'; + var scriptSig = Script.fromHumanReadable(scriptSigHR); + + ScriptInterpreter.verifyFull(scriptSig, scriptPubKey, undefined, undefined, + undefined, undefined, function(err, result) { + console.log('script verified successfully? ', result) + }) +}; + +module.exports.run = run; +if (require.main === module) { + run(); +}