diff options
Diffstat (limited to 'src/ark/manager.js')
| -rw-r--r-- | src/ark/manager.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/ark/manager.js b/src/ark/manager.js index 8be9d58..fc298d9 100644 --- a/src/ark/manager.js +++ b/src/ark/manager.js @@ -506,15 +506,30 @@ export class ArkManager { // ---- public surface ---- address() { - const k0 = this._key(0); - const blinded = blindMailboxId(this._mailboxKey().pubkey, hex.decode(this.info.mailboxPubkey), k0.privkey); + return this._addressFor(0); + } + // The address of one of this wallet's keys. The mailbox id is blinded with + // that key, as the server unblinds it against the key the address names. + _addressFor(keyIndex) { + const k = this._key(keyIndex); + const blinded = blindMailboxId(this._mailboxKey().pubkey, hex.decode(this.info.mailboxPubkey), k.privkey); return encodeAddress({ testnet: this.info.network !== 'bitcoin', serverPubkey: this.serverPub, - userPubkey: k0.pubkey, + userPubkey: k.pubkey, blindedMailboxId: blinded, }); } + // A receive address on a key of its own, for a service that has to tell + // its payers apart (the server-to-server migrator hands one out per + // migration). Coins paid to it arrive through the same mailbox and are + // recorded with that keyIndex. + freshAddress() { + const keyIndex = this.state.nextKeyIndex || 1; + this.state.nextKeyIndex = keyIndex + 1; + this._save(); + return { keyIndex, address: this._addressFor(keyIndex) }; + } // A coin past its expiry is money only the server still honors: the // recipient's validator refuses anything expired at pickup time, so sending |
