Merge pull request #240 from braydonf/gettxoutsetinfo
Add binding for getting transaction output set information.
This commit is contained in:
commit
4a5031a917
@ -410,4 +410,24 @@ describe('Daemon Binding Functionality', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('get transaction output set information', function() {
|
||||||
|
var bestblock;
|
||||||
|
it('will get the correct info', function() {
|
||||||
|
var info = bitcoind.getTxOutSetInfo();
|
||||||
|
info.bestblock.should.be.a('string');
|
||||||
|
bestblock = info.bestblock;
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
it('will get the best block hash', function() {
|
||||||
|
var best = bitcoind.getBestBlockHash();
|
||||||
|
best.should.equal(bestblock);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -224,6 +224,14 @@ Bitcoin.prototype.addMempoolUncheckedTransaction = function(txBuffer) {
|
|||||||
return bindings.addMempoolUncheckedTransaction(txBuffer);
|
return bindings.addMempoolUncheckedTransaction(txBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Bitcoin.prototype.getBestBlockHash = function() {
|
||||||
|
return bindings.getBestBlockHash();
|
||||||
|
};
|
||||||
|
|
||||||
|
Bitcoin.prototype.getTxOutSetInfo = function() {
|
||||||
|
return bindings.getTxOutSetInfo();
|
||||||
|
};
|
||||||
|
|
||||||
Bitcoin.prototype.getInfo = function() {
|
Bitcoin.prototype.getInfo = function() {
|
||||||
return bindings.getInfo();
|
return bindings.getInfo();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -203,6 +203,39 @@ NAN_METHOD(SyncPercentage) {
|
|||||||
NanReturnValue(NanNew<Number>(progress * 100));
|
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());
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
NAN_METHOD(GetBestBlockHash) {
|
||||||
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
|
NanReturnValue(NanNew<String>(chainActive.Tip()->GetBlockHash().GetHex()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IsSynced()
|
* IsSynced()
|
||||||
* bitcoind.isSynced()
|
* bitcoind.isSynced()
|
||||||
@ -1629,6 +1662,8 @@ init(Handle<Object> target) {
|
|||||||
NODE_SET_METHOD(target, "startTxMon", StartTxMon);
|
NODE_SET_METHOD(target, "startTxMon", StartTxMon);
|
||||||
NODE_SET_METHOD(target, "syncPercentage", SyncPercentage);
|
NODE_SET_METHOD(target, "syncPercentage", SyncPercentage);
|
||||||
NODE_SET_METHOD(target, "isSynced", IsSynced);
|
NODE_SET_METHOD(target, "isSynced", IsSynced);
|
||||||
|
NODE_SET_METHOD(target, "getTxOutSetInfo", GetTxOutSetInfo);
|
||||||
|
NODE_SET_METHOD(target, "getBestBlockHash", GetBestBlockHash);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,3 +36,5 @@ NAN_METHOD(EstimateFee);
|
|||||||
NAN_METHOD(StartTxMon);
|
NAN_METHOD(StartTxMon);
|
||||||
NAN_METHOD(SyncPercentage);
|
NAN_METHOD(SyncPercentage);
|
||||||
NAN_METHOD(IsSynced);
|
NAN_METHOD(IsSynced);
|
||||||
|
NAN_METHOD(GetTxOutSetInfo);
|
||||||
|
NAN_METHOD(GetBestBlockHash);
|
||||||
|
|||||||
@ -408,6 +408,8 @@ describe('Bitcoin Service', function() {
|
|||||||
['getTransactionWithBlockInfo', 3],
|
['getTransactionWithBlockInfo', 3],
|
||||||
['getMempoolTransactions', 0],
|
['getMempoolTransactions', 0],
|
||||||
['addMempoolUncheckedTransaction', 1],
|
['addMempoolUncheckedTransaction', 1],
|
||||||
|
['getTxOutSetInfo', 0],
|
||||||
|
['getBestBlockHash', 0],
|
||||||
['getInfo', 0]
|
['getInfo', 0]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user