Add binding to get the best block hash.
This commit is contained in:
parent
4c674a8fbb
commit
68368397d3
@ -400,9 +400,11 @@ describe('Daemon Binding Functionality', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('get transaction output set information', function() {
|
describe('get transaction output set information', function() {
|
||||||
|
var bestblock;
|
||||||
it('will get the correct info', function() {
|
it('will get the correct info', function() {
|
||||||
var info = bitcoind.getTxOutSetInfo();
|
var info = bitcoind.getTxOutSetInfo();
|
||||||
info.bestblock.should.be.a('string');
|
info.bestblock.should.be.a('string');
|
||||||
|
bestblock = info.bestblock;
|
||||||
info.bestblock.length.should.equal(64);
|
info.bestblock.length.should.equal(64);
|
||||||
info.bytes_serialized.should.equal(10431);
|
info.bytes_serialized.should.equal(10431);
|
||||||
info.hash_serialized.should.be.a('string');
|
info.hash_serialized.should.be.a('string');
|
||||||
@ -412,5 +414,9 @@ describe('Daemon Binding Functionality', function() {
|
|||||||
info.transactions.should.equal(151);
|
info.transactions.should.equal(151);
|
||||||
info.txouts.should.equal(151);
|
info.txouts.should.equal(151);
|
||||||
});
|
});
|
||||||
|
it('will get the best block hash', function() {
|
||||||
|
var best = bitcoind.getBestBlockHash();
|
||||||
|
best.should.equal(bestblock);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -223,6 +223,10 @@ Bitcoin.prototype.addMempoolUncheckedTransaction = function(txBuffer) {
|
|||||||
return bindings.addMempoolUncheckedTransaction(txBuffer);
|
return bindings.addMempoolUncheckedTransaction(txBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Bitcoin.prototype.getBestBlockHash = function() {
|
||||||
|
return bindings.getBestBlockHash();
|
||||||
|
};
|
||||||
|
|
||||||
Bitcoin.prototype.getTxOutSetInfo = function() {
|
Bitcoin.prototype.getTxOutSetInfo = function() {
|
||||||
return bindings.getTxOutSetInfo();
|
return bindings.getTxOutSetInfo();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -229,6 +229,13 @@ NAN_METHOD(GetTxOutSetInfo) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
NAN_METHOD(GetBestBlockHash) {
|
||||||
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
|
NanReturnValue(NanNew<String>(chainActive.Tip()->GetBlockHash().GetHex()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IsSynced()
|
* IsSynced()
|
||||||
* bitcoind.isSynced()
|
* bitcoind.isSynced()
|
||||||
@ -1702,6 +1709,7 @@ init(Handle<Object> target) {
|
|||||||
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, "getTxOutSetInfo", GetTxOutSetInfo);
|
||||||
|
NODE_SET_METHOD(target, "getBestBlockHash", GetBestBlockHash);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,3 +37,4 @@ NAN_METHOD(StartTxMon);
|
|||||||
NAN_METHOD(SyncPercentage);
|
NAN_METHOD(SyncPercentage);
|
||||||
NAN_METHOD(IsSynced);
|
NAN_METHOD(IsSynced);
|
||||||
NAN_METHOD(GetTxOutSetInfo);
|
NAN_METHOD(GetTxOutSetInfo);
|
||||||
|
NAN_METHOD(GetBestBlockHash);
|
||||||
|
|||||||
@ -409,6 +409,7 @@ describe('Bitcoin Service', function() {
|
|||||||
['getMempoolOutputs', 1],
|
['getMempoolOutputs', 1],
|
||||||
['addMempoolUncheckedTransaction', 1],
|
['addMempoolUncheckedTransaction', 1],
|
||||||
['getTxOutSetInfo', 0],
|
['getTxOutSetInfo', 0],
|
||||||
|
['getBestBlockHash', 0],
|
||||||
['getInfo', 0]
|
['getInfo', 0]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user