wallet improvements.

This commit is contained in:
Christopher Jeffrey 2016-02-29 14:47:57 -08:00
parent 3740281232
commit c41ded7360
3 changed files with 18 additions and 13 deletions

View File

@ -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) {
var self = this;
var coin;

View File

@ -83,6 +83,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
this._all[hash].ts = tx.ts;
this._all[hash].block = tx.block;
this._all[hash].height = tx.height;
this._all[hash].index = tx.index;
this._all[hash].outputs.forEach(function(output, i) {
var key = hash + '/' + i;
if (this._unspent[key])
@ -294,6 +295,7 @@ TXPool.prototype.unconfirm = function unconfirm(hash) {
tx.ts = 0;
tx.block = null;
tx.height = -1;
tx.index = -1;
tx.outputs.forEach(function(output, i) {
var key = hash + '/' + i;
if (this._unspent[key])

View File

@ -535,10 +535,11 @@ Wallet.prototype.fill = function fill(tx, options) {
assert(this._initialized);
tx.fill(this.getUnspent(), {
// wallet: this,
selection: options.selection || 'age',
fee: options.fee,
subtractFee: options.subtractFee,
changeAddress: this.changeAddress.getAddress(),
wallet: this,
m: this.m,
n: this.n
});
@ -546,21 +547,19 @@ Wallet.prototype.fill = function fill(tx, options) {
return true;
};
// Legacy
Wallet.prototype.fillUnspent = Wallet.prototype.fill;
Wallet.prototype.fillInputs = Wallet.prototype.fill;
Wallet.prototype.fillPrevout = function fillPrevout(tx) {
return tx.fillPrevout(this);
};
// Legacy
Wallet.prototype.fillTX = Wallet.prototype.fillPrevout;
Wallet.prototype.createTX = function createTX(outputs, options) {
var tx = bcoin.tx();
Wallet.prototype.createTX = function createTX(options, outputs) {
var tx = bcoin.mtx();
var target;
if (!outputs) {
outputs = options;
options = {};
}
if (!Array.isArray(outputs))
outputs = [outputs];
@ -841,9 +840,9 @@ Wallet.prototype.__defineGetter__('scriptAddress', function() {
return this.getScriptAddress();
});
// Wallet.prototype.__defineGetter__('program', function() {
// return this.getProgram();
// });
Wallet.prototype.__defineGetter__('program', function() {
return this.getProgram();
});
Wallet.prototype.__defineGetter__('programHash', function() {
return this.getProgramHash();