From ef903bae07c600bb0eb1e17e406646a494205f43 Mon Sep 17 00:00:00 2001 From: booo Date: Wed, 28 Dec 2011 16:29:16 +0100 Subject: [PATCH] src/wallet: getNextAddresss: add new address if necessary --- src/wallet.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wallet.js b/src/wallet.js index 0fd3406..28f3c1f 100755 --- a/src/wallet.js +++ b/src/wallet.js @@ -95,13 +95,11 @@ Bitcoin.Wallet = (function () { }; this.getNextAddress = function () { - if (keys.length) { - // TODO: Create new addresses if we run out - this.addressPointer = (this.addressPointer + 1) % keys.length; - return keys[this.addressPointer].getBitcoinAddress(); - } else { - return null; + this.addressPointer++; + if(!keys[this.addressPointer]) { + this.generateAddress(); } + return keys[this.addressPointer].getBitcoinAddress(); }; this.signWithKey = function (pubKeyHash, hash) {