Merge pull request #208 from kleetus/errorMessage_todo
Performed lexical cast on the reject code instead of using a sprintf.
This commit is contained in:
commit
8c0ff7ba24
|
@ -275,6 +275,17 @@ describe('Daemon Binding Functionality', function() {
|
||||||
hash.should.equal(tx.hash);
|
hash.should.equal(tx.hash);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('will throw an error if an unsigned transaction is sent', function() {
|
||||||
|
|
||||||
|
var tx = bitcore.Transaction();
|
||||||
|
tx.from(utxos[1]);
|
||||||
|
tx.change(privateKey.toAddress());
|
||||||
|
tx.to(destKey.toAddress(), utxos[1].amount * 1e8 - 1000);
|
||||||
|
(function() {
|
||||||
|
bitcoind.sendTransaction(tx.uncheckedSerialize());
|
||||||
|
}).should.throw('\x10: mandatory-script-verify-flag-failed (Operation not valid with the current stack size)');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('fee estimation', function() {
|
describe('fee estimation', function() {
|
||||||
|
|
|
@ -1478,10 +1478,7 @@ NAN_METHOD(SendTransaction) {
|
||||||
// Attempt to add the transaction to the mempool
|
// Attempt to add the transaction to the mempool
|
||||||
if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !allowAbsurdFees)) {
|
if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !allowAbsurdFees)) {
|
||||||
if (state.IsInvalid()) {
|
if (state.IsInvalid()) {
|
||||||
// TODO: use boost::lexical_cast or C++11 std::to_string
|
return NanThrowError((boost::lexical_cast<std::string>(state.GetRejectCode()) + ": " + state.GetRejectReason()).c_str());
|
||||||
char errorMessage [1024];
|
|
||||||
sprintf(errorMessage, "%i: %s", state.GetRejectCode(), state.GetRejectReason().c_str());
|
|
||||||
return NanThrowError(errorMessage);
|
|
||||||
} else {
|
} else {
|
||||||
if (fMissingInputs) {
|
if (fMissingInputs) {
|
||||||
return NanThrowError("Missing inputs");
|
return NanThrowError("Missing inputs");
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "txdb.h"
|
#include "txdb.h"
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
#include "nan.h"
|
#include "nan.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "core_io.h"
|
#include "core_io.h"
|
||||||
|
|
Loading…
Reference in New Issue