From 8349e537d97d7bbd6aa15ad6220deadb61d8720a Mon Sep 17 00:00:00 2001 From: olalonde Date: Tue, 8 Apr 2014 14:32:51 +0800 Subject: [PATCH] Added PayToScriptHashAddress example --- examples/PayToScriptHashAddress.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/PayToScriptHashAddress.js diff --git a/examples/PayToScriptHashAddress.js b/examples/PayToScriptHashAddress.js new file mode 100644 index 0000000..846d6d2 --- /dev/null +++ b/examples/PayToScriptHashAddress.js @@ -0,0 +1,17 @@ +var bitcore = require('../bitcore'); +var Address = bitcore.Address; +var bitcoreUtil = bitcore.util; +var Script = bitcore.Script; +var network = bitcore.networks.livenet; + + +var script = ''; // write down your script here +var s = Script.fromHumanReadable(script); +var hash = bitcoreUtil.sha256ripe160(s.getBuffer()); +var version = network.addressScript; + +var addr = new Address(version, hash); +var addrStr = addr.as('base58'); + +// This outputs the "address" of thescript +console.log(addrStr);