bwc
This commit is contained in:
parent
04fb7ba032
commit
320de62f13
348 changed files with 7745 additions and 30874 deletions
|
|
@ -1,69 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var bitcore = require('bitcore');
|
||||
|
||||
function FakeBlockchain(opts) {
|
||||
opts = opts || {};
|
||||
}
|
||||
|
||||
FakeBlockchain.prototype.getTransaction = function(txid, cb) {
|
||||
return cb(null, {txid: txid});
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.getTransactions = function(addresses, from, to, cb) {
|
||||
cb(null, { totalItems: 0, items: [] });
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.subscribe = function() {
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.on = function() {
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.fixUnspent = function(u) {
|
||||
this.u = u;
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.destroy = function() {
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.getUnspent = function(addresses, cb) {
|
||||
return cb(null, this.u || [{
|
||||
'address': 'mji7zocy8QzYywQakwWf99w9bCT6orY1C1',
|
||||
'txid': '0be0fb4579911be829e3077202e1ab47fcc12cf3ab8f8487ccceae768e1f95fa',
|
||||
'vout': 0,
|
||||
'ts': 1402323949,
|
||||
'scriptPubKey': '21032ca453c1d9a93b7de8cf3d44d7bb8d52a45dbdf8fff63f69de4e51b740bb1da3ac',
|
||||
'amount': 25.0001,
|
||||
'confirmations': 0,
|
||||
'confirmationsFromCache': false
|
||||
}]);
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.getUnspent2 = function(addresses, cb) {
|
||||
return cb(null, this.u || [{
|
||||
'address': 'mji7zocy8QzYywQakwWf99w9bCT6orY1C1',
|
||||
'txid': '0be0fb4579911be829e3077202e1ab47fcc12cf3ab8f8487ccceae768e1f95fa',
|
||||
'vout': 0,
|
||||
'ts': 1402323949,
|
||||
'scriptPubKey': '21032ca453c1d9a93b7de8cf3d44d7bb8d52a45dbdf8fff63f69de4e51b740bb1da3ac',
|
||||
'amount': 25.0001,
|
||||
'confirmations': 1,
|
||||
'confirmationsFromCache': false
|
||||
}]);
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.broadcast = function(rawtx, cb) {
|
||||
var txid = '0be0fb4579911be829e3077202e1ab47fcc12cf3ab8f8487ccceae768e1f95fa';
|
||||
return cb(null, txid);
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.checkSentTx = function (tx, cb) {
|
||||
var txid = '0be0fb4579911be829e3077202e1ab47fcc12cf3ab8f8487ccceae768e1f95fa';
|
||||
return cb(null, txid);
|
||||
};
|
||||
|
||||
FakeBlockchain.prototype.removeAllListeners = function() {
|
||||
};
|
||||
|
||||
module.exports = FakeBlockchain;
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
var FakeSocket = function (url, opts) {
|
||||
var self = this;
|
||||
|
||||
self.connected = false;
|
||||
setTimeout(function() {
|
||||
self.connected = true;
|
||||
self.emit('connect');
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var inherits = function(ctor, superCtor) {
|
||||
ctor.super_ = superCtor;
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
inherits(FakeSocket, EventEmitter);
|
||||
|
||||
FakeSocket.prototype.removeListener = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FakeSocket.prototype.destroy = function() {
|
||||
this.connected = false;
|
||||
this.removeAllListeners();
|
||||
};
|
||||
|
||||
|
||||
FakeSocket.prototype.disconnect = function() {
|
||||
this.destroy();
|
||||
};
|
||||
|
||||
module.exports = FakeSocket;
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
function Network(opts) {}
|
||||
|
||||
util.inherits(Network, EventEmitter);
|
||||
|
||||
Network.prototype.start = function(opts, cb) {
|
||||
this.peer = {
|
||||
options: {
|
||||
token: "asd"
|
||||
}
|
||||
};
|
||||
if (cb) cb();
|
||||
};
|
||||
|
||||
Network.prototype.send = function(peerIds, data, cb) {};
|
||||
|
||||
Network.prototype.connectTo = function(peerId) {};
|
||||
|
||||
|
||||
Network.prototype.disconnect = function(cb) {};
|
||||
|
||||
Network.prototype.lockIncommingConnections = function() {
|
||||
|
||||
};
|
||||
|
||||
Network.prototype.getPeer = function() {};
|
||||
Network.prototype.connectToCopayers = function(cps) {};
|
||||
Network.prototype.isOnline = function() {
|
||||
return true;
|
||||
};
|
||||
Network.prototype.peerFromCopayer = function(copayerId) {
|
||||
return copayerId;
|
||||
};
|
||||
|
||||
//hex version of one's own nonce
|
||||
Network.prototype.setHexNonce = function(networkNonce) {
|
||||
if (networkNonce && networkNonce.length === 16)
|
||||
this.networkNonce = new Buffer(networkNonce, 'hex');
|
||||
else
|
||||
this.iterateNonce();
|
||||
};
|
||||
|
||||
//hex version of copayers' nonces
|
||||
Network.prototype.setHexNonces = function(networkNonces) {
|
||||
for (var i in networkNonces) {
|
||||
if (!this.networkNonces)
|
||||
this.networkNonces = {};
|
||||
if (networkNonces[i].length === 16)
|
||||
this.networkNonces[i] = new Buffer(networkNonces[i], 'hex');
|
||||
}
|
||||
};
|
||||
|
||||
//for oneself
|
||||
Network.prototype.getHexNonce = function() {
|
||||
return this.networkNonce.toString('hex');
|
||||
};
|
||||
|
||||
//for copayers
|
||||
Network.prototype.getHexNonces = function() {
|
||||
var networkNoncesHex = [];
|
||||
for (var i in this.networkNonces) {
|
||||
networkNoncesHex = this.networkNonces[i].toString('hex');
|
||||
}
|
||||
return networkNoncesHex;
|
||||
};
|
||||
|
||||
Network.prototype.iterateNonce = function() {
|
||||
if (!this.networkNonce || this.networkNonce.length !== 8) {
|
||||
this.networkNonce = new Buffer(8);
|
||||
this.networkNonce.fill(0);
|
||||
this.networkNonce[7] = 1;
|
||||
return this.networkNonce;
|
||||
}
|
||||
//the first 4 bytes of a nonce is a unix timestamp in seconds
|
||||
//the second 4 bytes is just an iterated "sub" nonce
|
||||
//the whole thing is interpreted as one big endian number
|
||||
var noncep1 = this.networkNonce.slice(0, 4);
|
||||
noncep1.writeUInt32BE(Math.floor(Date.now() / 1000), 0);
|
||||
var noncep2uint = this.networkNonce.slice(4, 8).readUInt32BE(0);
|
||||
var noncep2 = this.networkNonce.slice(4, 8);
|
||||
noncep2.writeUInt32BE(noncep2uint + 1, 0);
|
||||
return this.networkNonce;
|
||||
};
|
||||
|
||||
|
||||
Network.prototype.cleanUp = function() {
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
module.exports = Network;
|
||||
Loading…
Add table
Add a link
Reference in a new issue