From bb8e43117c139ddd071b8d16d5d58ee2409a2161 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 17 Nov 2014 13:13:55 -0800 Subject: [PATCH] refactor. fix boolean cast. --- src/bitcoindjs.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 92724972..fc7a8e44 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -1482,7 +1482,6 @@ NAN_METHOD(FillTransaction) { } Local jstx = Local::Cast(args[0]); - // Local options = Local::Cast(args[1]); String::Utf8Value tx_hex_(jstx->Get(NanNew("hex"))->ToString()); std::string tx_hex = std::string(*tx_hex_); @@ -1500,14 +1499,17 @@ NAN_METHOD(FillTransaction) { nValue += value; } - if (nValue <= 0) + if (nValue <= 0) { return NanThrowError("Invalid amount"); + } + // With v0.9.0: // if (nValue + nTransactionFee > pwalletMain->GetBalance()) // if (nValue + payTxFee > pwalletMain->GetBalance()) // return NanThrowError("Insufficient funds"); - if (nValue > pwalletMain->GetBalance()) + if (nValue > pwalletMain->GetBalance()) { return NanThrowError("Insufficient funds"); + } // With v0.9.0: // int64_t nFeeRet = nTransactionFee; @@ -1540,8 +1542,8 @@ NAN_METHOD(FillTransaction) { (const CKeyStore&)*pwalletMain, (const CTransaction&)*coin.first, (CMutableTransaction&)ctx, - nIn++) - ) { + nIn++ + )) { return NanThrowError("Signing transaction failed"); } } @@ -1727,8 +1729,7 @@ NAN_METHOD(GetProgress) { async_block_data *data = new async_block_data(); data->err_msg = std::string(""); CBlockIndex *pindex = chainActive.Tip(); - data->hash = pindex->GetBlockHash().GetHex(); // .ToString(); - //data->hash = pcoinsTip->GetBestBlock().GetHex(); // .ToString(); + data->hash = pindex->GetBlockHash().GetHex(); data->height = -1; data->callback = Persistent::New(callback); @@ -1885,7 +1886,7 @@ NAN_METHOD(SetGenerate) { } } else { // Not -regtest: start generate thread, return immediately mapArgs["-gen"] = (fGenerate ? "1" : "0"); - mapArgs ["-genproclimit"] = itostr(nGenProcLimit); + mapArgs["-genproclimit"] = itostr(nGenProcLimit); GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); } @@ -4299,7 +4300,7 @@ NAN_METHOD(WalletGetTransaction) { isminefilter filter = ISMINE_SPENDABLE; if (options->Get(NanNew("watch"))->IsBoolean() - && options->Get(NanNew("watch"))->IsTrue()) { + && options->Get(NanNew("watch"))->ToBoolean->IsTrue()) { filter = filter | ISMINE_WATCH_ONLY; }