- Notifications
You must be signed in to change notification settings - Fork0
panda-suite/pandacash-core
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is the core code that powers the Pandacash application and the the Pandacash command line tool -pandacash-cli
.
To runpandacash-cli
, make sure thatNode.js is installed.On macOS these tools can be installed throughHomebrew.
brew install node
npm install pandacash-core
As a general HTTP server
constpanda=require("pandacash-core");constserver=panda.server({// optional, will be generated if not providermnemonic:"cigar magnet ocean purchase travel damp snack alone theme budget wagon wrong",// default: 10totalAccounts:10,// will log in the consoleenableLogs:true,// will show logs from the bch nodedebug:false,// options: "cash", "legacy", "both"addressFormat:"both",});constpandaCashCore=awaitserver.listen({port:48332,walletPort:48334});console.log("Mnemonic: "+pandaCashCore.opts.mnemonic);console.log("Account[0] public key (cash format): "+pandaCashCore.account.keyPairs[0].cashAddress);console.log("Account[0] public key (legacy format): "+pandaCashCore.account.keyPairs[0].legacyAddress);console.log("Account[0] private key: "+pandaCashCore.account.keyPairs[0].privateKey);
In Jasmine/Mocha tests
constpanda=require("pandacash-core")beforeAll(done=>{constserver=panda.server({enableLogs:false,debug:false})(async()=>{try{awaitserver.listen({port:48332walletPort:48334});}catch(err){returndone(err);}done();})();});
bch.js is a lightweight RPC client for Bitcoin Cash. Panda is fully integrated withbchjs
. An instance of the library is exposed underpandacashCore.bch
.
constpanda=require("pandacash-core");constserver=panda.server();constpandacashCore=awaitserver.listen({port:48334,walletPort:48335});constblockchainInfo=awaitpandacashCore.bch.getblockchaininfo();console.log(blockchainInfo);
constpandaCashCore=awaitserver.listen({port:8081,walletPort:8082});// bch rpc works only with the bcash format!// find full documentation here: https://www.npmjs.com/package/bchjsconstunspentTxs=awaitpandaCashCore.bch.listunspent(0,20,[pandaCashCore.account.keyPairs[0].cashAddress]);const_utxo=unspentTxs[0];console.log(_utxo);/* { txid: 'a5872579aec7e509f17461e19d3d94c52ef29eceb2ba2116e6c5db164d3d0a57', vout: 0, address: 'bchreg:qzhv7vkn72wd5egeum0su9jjkjzv6q70zg83rchfz5', account: 'default', scriptPubKey: '76a914aecf32d3f29cda6519e6df0e1652b484cd03cf1288ac', amount: 25, confirmations: 20, spendable: true, solvable: true }*/constutxo={'txId' :_utxo.txid,'outputIndex' :_utxo.vout,'address' :pandaCashCore.account.keyPairs[0].legacyAddress,'script' :_utxo.scriptPubKey,'satoshis' :_utxo.amount*1000000};bch.Networks.enableRegtest();constprivateKey=newbch.PrivateKey(pandaCashCore.account.keyPairs[0].privateKey,"regtest");consttransaction=newbch.Transaction().from(utxo).to(pandaCashCore.account.keyPairs[0].legacyAddress,15000).sign(privateKey);console.log(transaction.toString());
Pandacash is powered by the bcash implementation of Bitcoin Cash.
Copyright 2018 Panda Suite
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
Core code for pandacash