Add binding for getting transaction output set information.
This commit is contained in:
parent
f85a832d8c
commit
4c674a8fbb
|
@ -399,4 +399,18 @@ describe('Daemon Binding Functionality', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('get transaction output set information', function() {
|
||||
it('will get the correct info', function() {
|
||||
var info = bitcoind.getTxOutSetInfo();
|
||||
info.bestblock.should.be.a('string');
|
||||
info.bestblock.length.should.equal(64);
|
||||
info.bytes_serialized.should.equal(10431);
|
||||
info.hash_serialized.should.be.a('string');
|
||||
info.hash_serialized.length.should.equal(64);
|
||||
info.height.should.equal(151);
|
||||
info.total_amount.should.equal(750000000000);
|
||||
info.transactions.should.equal(151);
|
||||
info.txouts.should.equal(151);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -223,6 +223,10 @@ Bitcoin.prototype.addMempoolUncheckedTransaction = function(txBuffer) {
|
|||
return bindings.addMempoolUncheckedTransaction(txBuffer);
|
||||
};
|
||||
|
||||
Bitcoin.prototype.getTxOutSetInfo = function() {
|
||||
return bindings.getTxOutSetInfo();
|
||||
};
|
||||
|
||||
Bitcoin.prototype.getInfo = function() {
|
||||
return bindings.getInfo();
|
||||
};
|
||||
|
|
|
@ -203,6 +203,32 @@ NAN_METHOD(SyncPercentage) {
|
|||
NanReturnValue(NanNew<Number>(progress * 100));
|
||||
};
|
||||
|
||||
NAN_METHOD(GetTxOutSetInfo) {
|
||||
Isolate* isolate = args.GetIsolate();
|
||||
HandleScope scope(isolate);
|
||||
{
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
CCoinsStats stats;
|
||||
FlushStateToDisk();
|
||||
if (pcoinsTip->GetStats(stats)) {
|
||||
Local<Object> obj = NanNew<Object>();
|
||||
obj->Set(NanNew<String>("height"), NanNew<Number>((int64_t)stats.nHeight));
|
||||
obj->Set(NanNew<String>("bestblock"), NanNew<String>(stats.hashBlock.GetHex()));
|
||||
obj->Set(NanNew<String>("transactions"), NanNew<Number>((int64_t)stats.nTransactions));
|
||||
obj->Set(NanNew<String>("txouts"), NanNew<Number>((int64_t)stats.nTransactionOutputs));
|
||||
obj->Set(NanNew<String>("bytes_serialized"), NanNew<Number>((int64_t)stats.nSerializedSize));
|
||||
obj->Set(NanNew<String>("hash_serialized"), NanNew<String>(stats.hashSerialized.GetHex()));
|
||||
obj->Set(NanNew<String>("total_amount"), NanNew<Number>(stats.nTotalAmount));
|
||||
NanReturnValue(obj);
|
||||
}
|
||||
}
|
||||
|
||||
NanReturnValue(NanNull());
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* IsSynced()
|
||||
* bitcoind.isSynced()
|
||||
|
@ -1675,6 +1701,7 @@ init(Handle<Object> target) {
|
|||
NODE_SET_METHOD(target, "startTxMon", StartTxMon);
|
||||
NODE_SET_METHOD(target, "syncPercentage", SyncPercentage);
|
||||
NODE_SET_METHOD(target, "isSynced", IsSynced);
|
||||
NODE_SET_METHOD(target, "getTxOutSetInfo", GetTxOutSetInfo);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,3 +36,4 @@ NAN_METHOD(EstimateFee);
|
|||
NAN_METHOD(StartTxMon);
|
||||
NAN_METHOD(SyncPercentage);
|
||||
NAN_METHOD(IsSynced);
|
||||
NAN_METHOD(GetTxOutSetInfo);
|
||||
|
|
|
@ -408,6 +408,7 @@ describe('Bitcoin Service', function() {
|
|||
['getTransactionWithBlockInfo', 3],
|
||||
['getMempoolOutputs', 1],
|
||||
['addMempoolUncheckedTransaction', 1],
|
||||
['getTxOutSetInfo', 0],
|
||||
['getInfo', 0]
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue