wallet: emit all added TXs
This commit is contained in:
parent
af993dc66b
commit
17d0903a35
@ -114,6 +114,8 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
||||
if (!noWrite && this._storage)
|
||||
this._storeTX(hash, tx);
|
||||
|
||||
this.emit('tx', tx);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -125,6 +127,14 @@ TXPool.prototype._storeTX = function _storeTX(hash, tx) {
|
||||
});
|
||||
};
|
||||
|
||||
TXPool.prototype.all = function all() {
|
||||
return Object.keys(this._all).map(function(key) {
|
||||
return this._all[key];
|
||||
}, this).filter(function(item) {
|
||||
return this._wallet.own(item.tx, item.index);
|
||||
}, this);
|
||||
};
|
||||
|
||||
TXPool.prototype.unspent = function unspent() {
|
||||
return Object.keys(this._unspent).map(function(key) {
|
||||
return this._unspent[key];
|
||||
|
||||
@ -55,6 +55,10 @@ Wallet.prototype._init = function init() {
|
||||
prevBalance = b;
|
||||
});
|
||||
|
||||
this.tx.on('tx', function(tx) {
|
||||
self.emit('tx', tx);
|
||||
});
|
||||
|
||||
this.tx.once('load', function(ts) {
|
||||
self.emit('load', ts);
|
||||
});
|
||||
@ -195,6 +199,10 @@ Wallet.prototype.addTX = function addTX(tx, block) {
|
||||
return this.tx.add(tx);
|
||||
};
|
||||
|
||||
Wallet.prototype.all = function all() {
|
||||
return this.tx.all();
|
||||
};
|
||||
|
||||
Wallet.prototype.unspent = function unspent() {
|
||||
return this.tx.unspent();
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user