Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('will parse correctly', function() {
var value = '000186a1'; // height
value += '01'; // address type
value += '7821c0a3768aa9d1a37e16cf76002aef5373f1a8'; // address ripemd160 hash
var valueBuf = new Buffer(value, 'hex');
var key = 'b4f97411dadf3882296997ade99f4a0891b07e768a76898b837ac41d2c2622e7'; // walletId
key += '41124f8000000000'; // satoshis
key += '5dde1b67c1a1dbc459f56a71efcedbd06c9516c51a9f901067253341175615bc'; // txid
key += '00000003'; // index
var bufKey = new Buffer(key, 'hex');
var utxo = WalletUTXOBySatoshis.fromBuffer(bufKey, valueBuf, bitcore.Networks.testnet);
checkUTXO(utxo);
utxo = WalletUTXOBySatoshis.fromBuffer(key, valueBuf, bitcore.Networks.testnet);
checkUTXO(utxo);
});
});
"use strict";
module.exports.ApiClient = require("./lib/apiclient");
module.exports.Schema = require("./lib/schema");
module.exports.TransactionBuilder = require("./lib/transactionbuilder");
module.exports.LedgerPath = require("./lib/ledgerpath");
module.exports.RecordKey = require("./lib/recordkey");
module.exports.encoding = require("./lib/encoding");
module.exports.MutationSigner = require("./lib/mutationsigner");
module.exports.ByteBuffer = require("protobufjs").ByteBuffer;
module.exports.Long = require("protobufjs").Long;
// Create the "openchain" network
var bitcore = require("bitcore-lib");
var livenet = bitcore.Networks.get("livenet");
bitcore.Networks.add({
name: "openchain",
alias: "Openchain",
pubkeyhash: 76,
privatekey: livenet.privatekey,
scripthash: 78,
xpubkey: livenet.xpubkey,
xprivkey: livenet.xprivkey,
networkMagic: 0,
port: livenet.port,
dnsSeeds: livenet.dnsSeeds
});
var isAddressAnOutput = isAddressAnCPoint('output')
app.use(express.static('public'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
// view engine setup
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'hbs')
hbs.registerPartials(path.join(__dirname, 'views/partials'))
// set up locals as template data
hbs.localsAsTemplateData(app)
app.locals.isProduction = app.settings.env === 'production'
app.locals.isTest = app.settings.env === 'test'
app.locals.isLivenet = bitcore.Networks.defaultNetwork.name === 'livenet'
app.locals.defaultNetwork = bitcore.Networks.defaultNetwork.name
app.locals.site = config.get('app.site')
app.locals.year = new Date().getFullYear()
// register block and extends view helpers
var blocks = {}
hbs.registerHelper('extend', (name, context) => {
var block = blocks[name]
if (!block) {
block = blocks[name] = []
}
block.push(context.fn(this))
})
hbs.registerHelper('block', (name) => {
var val = (blocks[name] || []).join('\n')
"use strict";
module.exports.ApiClient = require("./lib/apiclient");
module.exports.Schema = require("./lib/schema");
module.exports.TransactionBuilder = require("./lib/transactionbuilder");
module.exports.LedgerPath = require("./lib/ledgerpath");
module.exports.RecordKey = require("./lib/recordkey");
module.exports.encoding = require("./lib/encoding");
module.exports.MutationSigner = require("./lib/mutationsigner");
module.exports.ByteBuffer = require("protobufjs").ByteBuffer;
module.exports.Long = require("protobufjs").Long;
// Create the "openchain" network
var bitcore = require("bitcore-lib");
var livenet = bitcore.Networks.get("livenet");
bitcore.Networks.add({
name: "openchain",
alias: "Openchain",
pubkeyhash: 76,
privatekey: livenet.privatekey,
scripthash: 78,
xpubkey: livenet.xpubkey,
xprivkey: livenet.xprivkey,
networkMagic: 0,
port: livenet.port,
dnsSeeds: livenet.dnsSeeds
});
var test = require('tape')
var Networks = require('bitcore-lib').Networks
var Node = require('../lib/node.js')
test('Node constructor', function (t) {
var HEIGHT = 1000
var node
t.test('setup', function (t) {
t.plan(1)
node = new Node({
network: Networks.testnet,
path: 'data/' + process.pid,
to: HEIGHT
})
node.on('error', console.log)
node.start(t.error)
})
it('sets properties correctly', function() {
var network = bitcore.Networks.defaultNetwork;
var messages = new Messages({
network: network,
Block: bitcore.Block,
Transaction: bitcore.Transaction
});
should.exist(messages.builder.commands);
should.exist(messages.builder.constructors);
messages.builder.constructors.Block.should.equal(bitcore.Block);
messages.builder.constructors.Transaction.should.equal(bitcore.Transaction);
messages.network.should.deep.equal(network);
});
it('network should be unique for each set of messages', function() {
middleware(req, res, function() {
req.network.should.equal(bitcore.Networks.testnet);
req.networkName.should.equal('testnet');
req.bitcoinHeight.should.equal(100);
req.bitcoinHash.should.equal('0000000000000000d33b25b34da5bc2968e149ecf44e5b794e1ec45700d0be3e');
done();
});
});
else if(title == "SuperEconomy")
title = 'Lowest';
else if(title == "Urgent")
min = min/2;
return {title, description: `${value} BTC ~ ${min} min${min > 1 ? 's' : ''}`, value: item.feePerKb, feePrice};
}
catch(e){
console.error(e);
}
return {title: title, description: '', value: 0, feePrice: 0};
}
axios.get(`https://bws.bitpay.com/bws/api/v2/feelevels/?coin=btc&network=${bitcore.Networks.defaultNetwork == bitcore.Networks.livenet ? 'livenet' : 'testnet'}`)
.then(({ data }) => {
let isDup = false, lastValue = 0, removeLevel = 'superEconomy';
for(let item of data){
if(lastValue == item.feePerKb){
isDup = true;
removeLevel = '';
}
if(!isDup && item.level != removeLevel){
result.unshift(calcTimeFee(item));
}
lastValue = item.feePerKb;
isDup = false;
}
Config.prototype.getDatabasePath = function() {
var databasePath;
if (this.network === bitcore.Networks.livenet) {
databasePath = path.resolve(this.path, './livenet.lmdb');
} else if (this.network === bitcore.Networks.testnet) {
if (this.network.regtestEnabled) {
databasePath = path.resolve(this.path, './regtest.lmdb');
} else {
databasePath = path.resolve(this.path, './testnet3.lmdb');
}
} else {
throw new TypeError('Unknown network: ' + this.network);
}
return databasePath;
};
createAddressPrivatekey(){
let bitcore = require('bitcore-lib');
let Mnemonic = require('bitcore-mnemonic');
bitcore.Networks.defaultNetwork = this.getNetwork();
var code = null;
if (this.mnemonic == ''){
code = new Mnemonic();
this.mnemonic = code.phrase;
}
else
code = new Mnemonic(this.mnemonic);
let xpriv = code.toHDPrivateKey();
let hdPrivateKey = new bitcore.HDPrivateKey(xpriv);
var derived = hdPrivateKey.derive("m/44'/{0}'/0'/0/0".format(this.coinType));
this.address = derived.privateKey.toAddress().toString();