wallet improvements.
This commit is contained in:
parent
3740281232
commit
c41ded7360
@ -139,6 +139,10 @@ Node.prototype._init = function _init() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Node.prototype.scanWallet = function scanWallet(callback) {
|
||||||
|
this.wallet.scan(this.getTXByAddress.bind(this), callback);
|
||||||
|
};
|
||||||
|
|
||||||
Node.prototype.getBlock = function getBlock(hash, callback) {
|
Node.prototype.getBlock = function getBlock(hash, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var coin;
|
var coin;
|
||||||
|
|||||||
@ -83,6 +83,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
this._all[hash].ts = tx.ts;
|
this._all[hash].ts = tx.ts;
|
||||||
this._all[hash].block = tx.block;
|
this._all[hash].block = tx.block;
|
||||||
this._all[hash].height = tx.height;
|
this._all[hash].height = tx.height;
|
||||||
|
this._all[hash].index = tx.index;
|
||||||
this._all[hash].outputs.forEach(function(output, i) {
|
this._all[hash].outputs.forEach(function(output, i) {
|
||||||
var key = hash + '/' + i;
|
var key = hash + '/' + i;
|
||||||
if (this._unspent[key])
|
if (this._unspent[key])
|
||||||
@ -294,6 +295,7 @@ TXPool.prototype.unconfirm = function unconfirm(hash) {
|
|||||||
tx.ts = 0;
|
tx.ts = 0;
|
||||||
tx.block = null;
|
tx.block = null;
|
||||||
tx.height = -1;
|
tx.height = -1;
|
||||||
|
tx.index = -1;
|
||||||
tx.outputs.forEach(function(output, i) {
|
tx.outputs.forEach(function(output, i) {
|
||||||
var key = hash + '/' + i;
|
var key = hash + '/' + i;
|
||||||
if (this._unspent[key])
|
if (this._unspent[key])
|
||||||
|
|||||||
@ -535,10 +535,11 @@ Wallet.prototype.fill = function fill(tx, options) {
|
|||||||
assert(this._initialized);
|
assert(this._initialized);
|
||||||
|
|
||||||
tx.fill(this.getUnspent(), {
|
tx.fill(this.getUnspent(), {
|
||||||
// wallet: this,
|
selection: options.selection || 'age',
|
||||||
fee: options.fee,
|
fee: options.fee,
|
||||||
subtractFee: options.subtractFee,
|
subtractFee: options.subtractFee,
|
||||||
changeAddress: this.changeAddress.getAddress(),
|
changeAddress: this.changeAddress.getAddress(),
|
||||||
|
wallet: this,
|
||||||
m: this.m,
|
m: this.m,
|
||||||
n: this.n
|
n: this.n
|
||||||
});
|
});
|
||||||
@ -546,21 +547,19 @@ Wallet.prototype.fill = function fill(tx, options) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Legacy
|
|
||||||
Wallet.prototype.fillUnspent = Wallet.prototype.fill;
|
|
||||||
Wallet.prototype.fillInputs = Wallet.prototype.fill;
|
|
||||||
|
|
||||||
Wallet.prototype.fillPrevout = function fillPrevout(tx) {
|
Wallet.prototype.fillPrevout = function fillPrevout(tx) {
|
||||||
return tx.fillPrevout(this);
|
return tx.fillPrevout(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Legacy
|
Wallet.prototype.createTX = function createTX(options, outputs) {
|
||||||
Wallet.prototype.fillTX = Wallet.prototype.fillPrevout;
|
var tx = bcoin.mtx();
|
||||||
|
|
||||||
Wallet.prototype.createTX = function createTX(outputs, options) {
|
|
||||||
var tx = bcoin.tx();
|
|
||||||
var target;
|
var target;
|
||||||
|
|
||||||
|
if (!outputs) {
|
||||||
|
outputs = options;
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
if (!Array.isArray(outputs))
|
if (!Array.isArray(outputs))
|
||||||
outputs = [outputs];
|
outputs = [outputs];
|
||||||
|
|
||||||
@ -841,9 +840,9 @@ Wallet.prototype.__defineGetter__('scriptAddress', function() {
|
|||||||
return this.getScriptAddress();
|
return this.getScriptAddress();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wallet.prototype.__defineGetter__('program', function() {
|
Wallet.prototype.__defineGetter__('program', function() {
|
||||||
// return this.getProgram();
|
return this.getProgram();
|
||||||
// });
|
});
|
||||||
|
|
||||||
Wallet.prototype.__defineGetter__('programHash', function() {
|
Wallet.prototype.__defineGetter__('programHash', function() {
|
||||||
return this.getProgramHash();
|
return this.getProgramHash();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user