From 544d48c8079fd31716d0d15c01d73f0d6bd4143c Mon Sep 17 00:00:00 2001 From: Will Dembinski Date: Sat, 21 Mar 2020 08:40:22 -0700 Subject: [PATCH 1/4] get idea across for introducing accounts to bids --- lib/wallet/layout.js | 2 +- lib/wallet/txdb.js | 2 ++ lib/wallet/wallet.js | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/wallet/layout.js b/lib/wallet/layout.js index 57a9295ef..6da301b38 100644 --- a/lib/wallet/layout.js +++ b/lib/wallet/layout.js @@ -95,7 +95,7 @@ exports.txdb = { // Name undo records U: bdb.key('U', ['hash256']), // Bids - i: bdb.key('i', ['hash256', 'hash256', 'uint32']), + i: bdb.key('i', ['hash256', 'hash256', 'uint32', 'uint32']), // Reveals B: bdb.key('B', ['hash256', 'hash256', 'uint32']), // Blinds diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index a22a1c80b..d3d80ffd2 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -1882,6 +1882,8 @@ class TXDB { lockup, blind, own: true + // Put acct here somehow. Can get using the `outpoint`? Poking around. + // account: 123 }); updated = true; diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index cf78b81ac..e85cb8657 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -1625,6 +1625,11 @@ class Wallet extends EventEmitter { assert(Number.isSafeInteger(value) && value >= 0); assert(Number.isSafeInteger(lockup) && lockup >= 0); assert((acct >>> 0) === acct || typeof acct === 'string'); + + if (acct != null) { + assert(acct >>> 0 === acct || typeof acct === "string"); + acct = await this.getAccountIndex(acct); + } if (!rules.verifyName(name)) throw new Error('Invalid name.'); From fb8d0835bfefb6f5eba7f2ba84e20fe85e387cb1 Mon Sep 17 00:00:00 2001 From: Will Dembinski Date: Sat, 21 Mar 2020 09:36:13 -0700 Subject: [PATCH 2/4] Add comment --- lib/wallet/layout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wallet/layout.js b/lib/wallet/layout.js index 6da301b38..babd96e1c 100644 --- a/lib/wallet/layout.js +++ b/lib/wallet/layout.js @@ -95,7 +95,7 @@ exports.txdb = { // Name undo records U: bdb.key('U', ['hash256']), // Bids - i: bdb.key('i', ['hash256', 'hash256', 'uint32', 'uint32']), + i: bdb.key('i', ['hash256', 'hash256', 'uint32', 'uint32']), // Im not entirely sure how bucket.iterator(...) works - im assuming order is important here. // Reveals B: bdb.key('B', ['hash256', 'hash256', 'uint32']), // Blinds From 21cfefeda84131f15210d53c3ed6ccff3bbcaa5d Mon Sep 17 00:00:00 2001 From: Will Dembinski Date: Sat, 21 Mar 2020 10:30:04 -0700 Subject: [PATCH 3/4] fix obvi syntax err --- lib/wallet/txdb.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index d3d80ffd2..07a90aacb 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -532,13 +532,14 @@ class TXDB { putBid(b, nameHash, outpoint, options) { const {hash, index} = outpoint; + const acct = options.account || 0 const bb = new BlindBid(); bb.nameHash = nameHash; bb.name = options.name; bb.lockup = options.lockup; bb.blind = options.blind; bb.own = options.own; - b.put(layout.i.encode(nameHash, hash, index), bb.encode()); + b.put(layout.i.encode(nameHash, hash, index, acct), bb.encode()); } /** @@ -1881,9 +1882,8 @@ class TXDB { name, lockup, blind, - own: true - // Put acct here somehow. Can get using the `outpoint`? Poking around. - // account: 123 + own: true, + account: path.account }); updated = true; From 3f4976e6f97eca0b317bac92f80392859c0c99ac Mon Sep 17 00:00:00 2001 From: Will Dembinski Date: Sat, 21 Mar 2020 10:32:11 -0700 Subject: [PATCH 4/4] intro assertion for putBid --- lib/wallet/txdb.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index 07a90aacb..6192a3a8e 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -532,7 +532,10 @@ class TXDB { putBid(b, nameHash, outpoint, options) { const {hash, index} = outpoint; - const acct = options.account || 0 + const acct = options.account + + assert(typeof acct === undefined || typeof acct === number) + const bb = new BlindBid(); bb.nameHash = nameHash; bb.name = options.name;