Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function testRpc() {
var client = jayson.client.http({
port: RPCPORT
});
var reqs = [
client.request('add', [1, 2, 3, 4, 5])
// client.request('rejection', [])
];
Promise.all(reqs).then(function(responses) {
console.log(responses)
});
}
it("proof test", async function() {
let oneStepProof = await OneStepProof.deployed();
var client = jayson.client.http('http://localhost:1235/rpc');
for (var i = 0; i < 508; i++) {
let response = await client.request('RPCInterface.GetProofData', [i]);
if (response.error != null) {
throw data.error;
}
let proofResult = await checkOneStepProof(
oneStepProof,
response.result.precondition,
response.result.assertion,
response.result.proof
);
if (proofResult.toNumber() != 0) {
console.log(`result ${i}, ${response.result.Instruction}: ${proofResult.toNumber()}`,);
}
}
var elements = [];
console.log(config.assertKeys);
for (var i = 0; i < config.assertKeys.length; i++) {
let addressBytes = Buffer.concat([Buffer.alloc(12), Buffer.from(config.assertKeys[i].slice(2), 'hex')]);
elements.push(addressBytes);
}
let tree = new MerkleTree(elements, true);
this.config = config;
this.vmTracker = vmTracker;
this.managerProof = tree.getProofOrdered(tree.elements[managerNum], managerNum + 1, true);
this.managerNum = managerNum;
this.vmId = vmId;
this.address = config.assertKeys[managerNum];
this.managerState = ManagerState.WAITING;
var client = jayson.client.http('http://localhost:1235/rpc');
this.client = client;
let self = this;
let registerData = {
"vmId": vmId,
"managerNum": managerNum
};
client.request('RPCInterface.RegisterVM', [registerData]).then(function(reponse) {
console.log("Registered VM", vmId, managerNum);
});
const disputableAssertionWatcher = vmTracker.DisputableAssertion({vmId: vmId});
disputableAssertionWatcher.watch(function(err, result) {
let data = {
"vmId": vmId,
"managerNum": managerNum,
function getRpcClient () {
return jayson.client.http('http://localhost:8545')
}
function client(endpoint) {
if (!endpoint) {
throw new Error('No endpoint provided for k0-server-client')
}
const jc = jayson.client.http(endpoint)
return {
cm: cm.bind(null, jc),
decryptNote: decryptNote.bind(null, jc),
depositCommitmentProof: depositCommitmentProof.bind(null, jc),
deriveKeys: deriveKeys.bind(null, jc),
encryptNote: encryptNote.bind(null, jc),
merkleTreeAdditionProof: merkleTreeAdditionProof.bind(null, jc),
pack256Bits: pack256Bits.bind(null, jc),
prepareTransfer: prepareTransfer.bind(null, jc),
prepare_withdrawal: prepare_withdrawal.bind(null, jc),
prfAddr: prfAddr.bind(null, jc),
status: status.bind(null, jc),
unpack256Bits: unpack256Bits.bind(null, jc),
verifyProof: verifyProof.bind(null, jc)
}
}
/**
* Cashier-BTC
* -----------
* Self-hosted bitcoin payment gateway
*
* https://github.com/Overtorment/Cashier-BTC
*
**/
let config = require('../config')
let jayson = require('jayson/promise')
let url = require('url')
let rpc = url.parse(config.bitcoind.rpc)
rpc.timeout = 5000
let client = jayson.client.http(rpc)
function importaddress (address) {
return client.request('importaddress', [address, address, false])
}
function getreceivedbyaddress (address) {
let reqs = [
client.request('getreceivedbyaddress', [address, 0]),
client.request('getreceivedbyaddress', [address, 3])
]
return Promise.all(reqs)
}
function getblockchaininfo () {
return client.request('getblockchaininfo', [])
export function setup ({ port }) {
client = jayson.client.tcp({ port })
METHODS.forEach(method => {
rpc[method] = (...args) => {
return client.request(method, args).then(ret => {
if (ret.error) throw ret.error.message
return ret.result
})
}
})
}
var fs = require('fs');
var sh = require('shelljs');
var keythereum = require('keythereum')
var Web3 = require('web3')
var web3 = new Web3()
var jsonfile = require('jsonfile')
var CU = require('./contractutils')
var _ = require('lodash')
var Promise = require("bluebird")
var request = require('request')
var jayson = require('jayson/promise')
const RPCURL = 'http://localhost:8545'
const SAVINGPATH = '/tmp/saving-latest.json'
//
var clientRpc = jayson.client.http(RPCURL);
web3.setProvider(new web3.providers.HttpProvider(RPCURL))
var rpcId = 0
function rpcPost(method, params) {
var requestData = {
jsonrpc: "2.0",
id: rpcId++,
method: method,
params: params
}
request({
url: RPCURL,
method: 'POST',
json: requestData
}, function(error, response, body) {
async function makeMT(endpoint) {
if (!endpoint) {
throw new Error('No Merkle tree server endpoint provided')
}
const jc = jayson.client.http(endpoint)
return {
add: add.bind(null, jc),
path: path.bind(null, jc),
reset: reset.bind(null, jc),
root: root.bind(null, jc),
simulateAdd: simulateAddition.bind(null, jc)
}
}