Expose estimateFee method.
This commit is contained in:
parent
bee86257ca
commit
2ca3a48884
@ -232,6 +232,13 @@ describe('Daemon Binding Functionality', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('fee estimation', function() {
|
||||||
|
it('will estimate fees', function() {
|
||||||
|
var fees = bitcoind.estimateFee();
|
||||||
|
fees.should.equal(-1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('tip updates', function() {
|
describe('tip updates', function() {
|
||||||
it('will get an event when the tip is new', function(done) {
|
it('will get an event when the tip is new', function(done) {
|
||||||
this.timeout(4000);
|
this.timeout(4000);
|
||||||
|
|||||||
@ -296,6 +296,10 @@ Daemon.prototype.getBlockIndex = function(blockHash) {
|
|||||||
return bitcoindjs.getBlockIndex(blockHash);
|
return bitcoindjs.getBlockIndex(blockHash);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Daemon.prototype.estimateFee = function(blocks) {
|
||||||
|
return bitcoindjs.estimateFee(blocks);
|
||||||
|
};
|
||||||
|
|
||||||
Daemon.prototype.sendTransaction = function(transaction, allowAbsurdFees) {
|
Daemon.prototype.sendTransaction = function(transaction, allowAbsurdFees) {
|
||||||
return bitcoindjs.sendTransaction(transaction, allowAbsurdFees);
|
return bitcoindjs.sendTransaction(transaction, allowAbsurdFees);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1121,6 +1121,33 @@ NAN_METHOD(GetInfo) {
|
|||||||
NanReturnValue(obj);
|
NanReturnValue(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimate Fee
|
||||||
|
* @blocks {number} - The number of blocks until confirmed
|
||||||
|
*/
|
||||||
|
|
||||||
|
NAN_METHOD(EstimateFee) {
|
||||||
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
|
HandleScope scope(isolate);
|
||||||
|
|
||||||
|
int nBlocks = args[0]->NumberValue();
|
||||||
|
if (nBlocks < 1) {
|
||||||
|
nBlocks = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFeeRate feeRate = mempool.estimateFee(nBlocks);
|
||||||
|
|
||||||
|
if (feeRate == CFeeRate(0)) {
|
||||||
|
NanReturnValue(NanNew<Number>(-1.0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAmount nFee = feeRate.GetFeePerK();
|
||||||
|
|
||||||
|
NanReturnValue(NanNew<Number>(nFee));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send Transaction
|
* Send Transaction
|
||||||
* bitcoindjs.sendTransaction()
|
* bitcoindjs.sendTransaction()
|
||||||
@ -1319,6 +1346,8 @@ init(Handle<Object> target) {
|
|||||||
NODE_SET_METHOD(target, "addMempoolUncheckedTransaction", AddMempoolUncheckedTransaction);
|
NODE_SET_METHOD(target, "addMempoolUncheckedTransaction", AddMempoolUncheckedTransaction);
|
||||||
NODE_SET_METHOD(target, "verifyScript", VerifyScript);
|
NODE_SET_METHOD(target, "verifyScript", VerifyScript);
|
||||||
NODE_SET_METHOD(target, "sendTransaction", SendTransaction);
|
NODE_SET_METHOD(target, "sendTransaction", SendTransaction);
|
||||||
|
NODE_SET_METHOD(target, "estimateFee", EstimateFee);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE_MODULE(bitcoindjs, init)
|
NODE_MODULE(bitcoindjs, init)
|
||||||
|
|||||||
@ -29,3 +29,4 @@ NAN_METHOD(GetMempoolOutputs);
|
|||||||
NAN_METHOD(AddMempoolUncheckedTransaction);
|
NAN_METHOD(AddMempoolUncheckedTransaction);
|
||||||
NAN_METHOD(VerifyScript);
|
NAN_METHOD(VerifyScript);
|
||||||
NAN_METHOD(SendTransaction);
|
NAN_METHOD(SendTransaction);
|
||||||
|
NAN_METHOD(EstimateFee);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user