Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO: use bitcore networks module
var genesisTXID = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b';
var CONCURRENCY = 10;
var DEFAULT_SAFE_CONFIRMATIONS = 6;
var MAX_OPEN_FILES = 500;
var END_OF_WORLD_TS = 1e13;
// var CONFIRMATION_NR_TO_NOT_CHECK = 10; //Spend
/**
* Module dependencies.
*/
var bitcore = require('bitcore'),
Rpc = imports.rpc || require('./Rpc'),
util = bitcore.util,
networks = bitcore.networks,
levelup = require('levelup'),
async = require('async'),
config = require('../config/config'),
assert = require('assert'),
Script = bitcore.Script,
bitcoreUtil = bitcore.util,
buffertools = require('buffertools');
var logger = require('./logger').logger;
var db = imports.db || levelup(config.leveldb + '/txs', {
maxOpenFiles: MAX_OPEN_FILES
});
var PoolMatch = imports.poolMatch || require('soop').load('./PoolMatch', config);
var Address = require('bitcore').Address;
var Base58 = bitcore.Base58;
var Address = bitcore.Address;
var Builder = bitcore.TransactionBuilder;
var Buffer = bitcore.Buffer;
var WalletKey = bitcore.WalletKey;
var Transaction = bitcore.Transaction;
var Script = bitcore.Script;
var coinUtil = bitcore.util;
var Bignum = bitcore.Bignum;
var buffertools = bitcore.buffertools;
var Key = bitcore.Key;
var Peer = bitcore.Peer;
var PeerManager = bitcore.PeerManager;
var network = bitcore.networks['testnet'];
var t1Transaction = null;
var t2Transaction = null;
var t3Transaction = null;
var ClientKey = null;
var serverPublicKey = null;
var serverPublicAddress = null;
var multisigScript = null;
var expireDate = 0;
var FEE_AMOUNT = 0.0001;
// Grabs the address in the browser and retrieves the balance (confirmed + unconfirmed)
function updateBalance() {
var Payment = require('../lib/transactions/Payment');
var opts = {
multisigOut: {"address":"2NGPp3oYGmpFokw4ZWux2jJU39i8zwfmTK5","txid":"17bb6b3f8f90a3aa7abd2ee4c3db7bc95a01bc9acd6cd919b2ac8eac367cfc7a","vout":1,"ts":1416181250,"scriptPubKey":"a914fdeaa734587dfed0090c98fbf1bf8730009ddda887","amount":0.009,"confirmationsFromCache":false},
amount: 90000,
changeAddress: new bitcore.Address('mrCHmWgn54hJNty2srFF4XLmkey5GnCv5m'),
paymentAddress: 'mzCXqcsLBerwyoRZzBFQELHaJ1ZtBSxxe6',
network: 'testnet',
pubKeys: con.commitmentTx.pubkeys
}
var e = new Payment(opts);
var conWalletKey = new bitcore.WalletKey({
privKey: conKey,
network: bitcore.networks['testnet']
});
var proWalletKey = new bitcore.WalletKey({
privKey: proKey,
network: bitcore.networks['testnet']
});
e.sign([conWalletKey]);
e.paymentTx = new Payment(JSON.parse(e.serialize()));
e.sign([proWalletKey]);
console.log(e.paid, e.build());
e.updateValue(1000);
e = new Payment(JSON.parse(e.serialize()));
e.sign([conWalletKey]);
e.sign([proWalletKey]);
console.log(e.paid, e.build());
var Refund = require('../lib/transactions/Refund');
var opts = {
multisigOut: {"address":"2NGPp3oYGmpFokw4ZWux2jJU39i8zwfmTK5","txid":"17bb6b3f8f90a3aa7abd2ee4c3db7bc95a01bc9acd6cd919b2ac8eac367cfc7a","vout":1,"ts":1416181250,"scriptPubKey":"a914fdeaa734587dfed0090c98fbf1bf8730009ddda887","amount":0.009,"confirmationsFromCache":false},
amount: 100000,
refundAddress: new bitcore.Address('mrCHmWgn54hJNty2srFF4XLmkey5GnCv5m'),
network: 'testnet',
pubKeys: con.commitmentTx.pubkeys,
lockTime: 1
}
var e = new Refund(opts);
var conWalletKey = new bitcore.WalletKey({
privKey: conKey,
network: bitcore.networks['testnet']
});
var proWalletKey = new bitcore.WalletKey({
privKey: proKey,
network: bitcore.networks['testnet']
});
e.sign([conWalletKey]);
e.sign([proWalletKey]);
e = new Refund(JSON.parse(e.serialize()));
console.log(e.build());
amount: 90000,
changeAddress: new bitcore.Address('mrCHmWgn54hJNty2srFF4XLmkey5GnCv5m'),
paymentAddress: 'mzCXqcsLBerwyoRZzBFQELHaJ1ZtBSxxe6',
network: 'testnet',
pubKeys: con.commitmentTx.pubkeys
}
var e = new Payment(opts);
var conWalletKey = new bitcore.WalletKey({
privKey: conKey,
network: bitcore.networks['testnet']
});
var proWalletKey = new bitcore.WalletKey({
privKey: proKey,
network: bitcore.networks['testnet']
});
e.sign([conWalletKey]);
e.paymentTx = new Payment(JSON.parse(e.serialize()));
e.sign([proWalletKey]);
console.log(e.paid, e.build());
e.updateValue(1000);
e = new Payment(JSON.parse(e.serialize()));
e.sign([conWalletKey]);
e.sign([proWalletKey]);
console.log(e.paid, e.build());
e.updateValue(1000);
e = new Payment(JSON.parse(e.serialize()));
e.sign([conWalletKey]);
e.sign([proWalletKey]);
console.log(e.paid, e.build());
'use strict';
var imports = require('soop').imports();
var config = imports.config || require('../config/config');
var bitcore = require('bitcore');
var networks = bitcore.networks;
var async = require('async');
var logger = require('./logger').logger;
var d = logger.log;
var info = logger.info;
var syncId = 0;
function Sync(opts) {
this.id = syncId++;
this.opts = opts || {};
this.bDb = require('./BlockDb').default();
this.txDb = require('./TransactionDb').default();
this.network = config.network === 'testnet' ? networks.testnet : networks.livenet;
'use strict';
var imports = require('soop').imports();
var util = require('util');
var async = require('async');
var bitcore = require('bitcore');
var networks = bitcore.networks;
var config = imports.config || require('../config/config');
var Sync = require('./Sync');
var sockets = require('../app/controllers/socket.js');
var BlockExtractor = require('./BlockExtractor.js');
var buffertools = require('buffertools');
var bitcoreUtil = bitcore.util;
var logger = require('./logger').logger;
var info = logger.info;
var error = logger.error;
var PERCENTAGE_TO_START_FROM_RPC = 0.96;
var BAD_GEN_ERROR = 'Bad genesis block. Network mismatch between bitcore-node and bitcoind? bitcore-node is configured for:';
var BAD_GEN_ERROR_DB = 'Bad genesis block. Network mismatch between bitcore-node and levelDB? bitcore-node is configured for:';
function HistoricSync(opts) {
opts = opts || {};