From 665a87f68051a3968e5306f11457103746e45e24 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 28 Oct 2014 11:29:33 -0700 Subject: [PATCH] allow to check whether wallet is encrypted. --- lib/bitcoind.js | 4 ++++ src/bitcoindjs.cc | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/bitcoind.js b/lib/bitcoind.js index d3fc3204..f79701e3 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -727,6 +727,10 @@ Wallet.prototype.encrypt = function(options) { return bitcoindjs.walletEncrypt(options || {}); }; +Wallet.prototype.isEncrypted = function() { + return bitcoindjs.walletEncrypted(); +}; + Wallet.prototype.setTxFee = function(options) { return bitcoindjs.walletSetTxFee(options || {}); }; diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index fea7a4b3..676a155c 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -192,6 +192,7 @@ NAN_METHOD(WalletPassphrase); NAN_METHOD(WalletPassphraseChange); NAN_METHOD(WalletLock); NAN_METHOD(WalletEncrypt); +NAN_METHOD(WalletEncrypted); NAN_METHOD(WalletSetTxFee); NAN_METHOD(WalletImportKey); @@ -3168,6 +3169,25 @@ NAN_METHOD(WalletEncrypt) { NanReturnValue(Undefined()); } +/** + * WalletEncrypted() + * bitcoindjs.walletEncrypted() + * Check whether the wallet is encrypted. + */ + +NAN_METHOD(WalletEncrypted) { + NanScope(); + + if (args.Length() > 0) { + return NanThrowError( + "Usage: bitcoindjs.walletEncrypted()"); + } + + bool isEncrypted = pwalletMain->IsCrypted(); + + NanReturnValue(NanNew(isEncrypted)); +} + /** * WalletSetTxFee() * bitcoindjs.walletSetTxFee(options) @@ -3712,6 +3732,7 @@ init(Handle target) { NODE_SET_METHOD(target, "walletPassphraseChange", WalletPassphraseChange); NODE_SET_METHOD(target, "walletLock", WalletLock); NODE_SET_METHOD(target, "walletEncrypt", WalletEncrypt); + NODE_SET_METHOD(target, "walletEncrypted", WalletEncrypted); NODE_SET_METHOD(target, "walletSetTxFee", WalletSetTxFee); NODE_SET_METHOD(target, "walletImportKey", WalletImportKey); }