From 98465d61e89ccedfeaa0c23fe6376a84bbdfbbac Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 29 Oct 2014 12:56:39 -0700 Subject: [PATCH] fix isEncrypted. --- lib/bitcoind.js | 10 +++++++++- src/bitcoindjs.cc | 12 +++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 4cd56d51..dafb4f1c 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -747,10 +747,18 @@ Wallet.prototype.encrypt = function(options) { return bitcoindjs.walletEncrypt(options || {}); }; -Wallet.prototype.isEncrypted = function() { +Wallet.prototype.encrypted = function() { return bitcoindjs.walletEncrypted(); }; +Wallet.prototype.isEncrypted = function() { + return this.encrypted().encrypted; +}; + +Wallet.prototype.isLocked = function() { + return this.encrypted().locked; +}; + Wallet.prototype.dumpKey = function(options) { return bitcoindjs.dumpKey(options || {}); }; diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index af4be3ca..99442ee8 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -3748,12 +3748,18 @@ NAN_METHOD(WalletEncrypted) { "Usage: bitcoindjs.walletEncrypted()"); } - bool isLocked = pwalletMain->IsLocked(); - bool isEncrypted = pwalletMain->IsCrypted(); + bool isLocked = false; + bool isEncrypted = false; + + isEncrypted = pwalletMain->IsCrypted(); + + if (isEncrypted) { + isLocked = pwalletMain->IsLocked(); + } Local result = NanNew(); result->Set(NanNew("locked"), NanNew(isLocked)); - result->Set(NanNew("encrypted"), NanNew(isCrypted)); + result->Set(NanNew("encrypted"), NanNew(isEncrypted)); NanReturnValue(result); }