Skip to content

Commit ef903ba

Browse files
committed
src/wallet: getNextAddresss: add new address if necessary
1 parent 3445ae2 commit ef903ba

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/wallet.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,11 @@ Bitcoin.Wallet = (function () {
9595
};
9696

9797
this.getNextAddress = function () {
98-
if (keys.length) {
99-
// TODO: Create new addresses if we run out
100-
this.addressPointer = (this.addressPointer + 1) % keys.length;
101-
return keys[this.addressPointer].getBitcoinAddress();
102-
} else {
103-
return null;
98+
this.addressPointer++;
99+
if(!keys[this.addressPointer]) {
100+
this.generateAddress();
104101
}
102+
return keys[this.addressPointer].getBitcoinAddress();
105103
};
106104

107105
this.signWithKey = function (pubKeyHash, hash) {

0 commit comments

Comments
 (0)