Skip to content

Commit

Permalink
Merge PR #899 from 'nodech/fix-methods'
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Aug 27, 2024
2 parents ceab2a8 + b010abc commit d754b86
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 55 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ process and allows parallel rescans.
- All transaction sending endpoints now fundlock/queue tx creation. (no more
conflicting transactions)
- Add options to `getNames` for passing `own`.
- Rename `createAuctionTxs` to `createAuctionTXs`.


## v6.0.0
Expand Down
6 changes: 3 additions & 3 deletions bin/hsw-cli
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class CLI {
this.log(tx);
}

async createAuctionTxs() {
async createAuctionTXs() {
const options = {
name: this.config.str([0, 'name']),
bid: this.config.ufixed([1, 'bid'], EXP),
Expand All @@ -381,7 +381,7 @@ class CLI {
passphrase: this.config.str('passphrase')
};

const txs = await this.wallet.createAuctionTxs(options);
const txs = await this.wallet.createAuctionTXs(options);

this.log(txs);
}
Expand Down Expand Up @@ -650,7 +650,7 @@ class CLI {
await this.getMaster();
break;
case 'mkauctiontxs':
await this.createAuctionTxs();
await this.createAuctionTXs();
break;
case 'mktx':
await this.createTX();
Expand Down
6 changes: 3 additions & 3 deletions lib/client/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ class WalletClient extends Client {
* @returns {Promise}
*/

createAuctionTxs(id, options) {
createAuctionTXs(id, options) {
return this.post(`/wallet/${id}/auction`, options);
}

Expand Down Expand Up @@ -1226,8 +1226,8 @@ class Wallet extends EventEmitter {
* @returns {Promise}
*/

createAuctionTxs(options) {
return this.client.createAuctionTxs(this.id, options);
createAuctionTXs(options) {
return this.client.createAuctionTXs(this.id, options);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions lib/wallet/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,29 +1151,29 @@ class HTTP extends Server {
enforce(broadcastBid ? sign : true, 'Must sign when broadcasting.');

const options = TransactionOptions.fromValidator(valid);
const auctionTxs = await req.wallet.createAuctionTxs(
const auctionTXs = await req.wallet.createAuctionTXs(
name,
bid,
lockup,
options
);

if (broadcastBid)
auctionTxs.bid = await req.wallet.sendMTX(auctionTxs.bid, passphrase);
auctionTXs.bid = await req.wallet.sendMTX(auctionTXs.bid, passphrase);

if (sign) {
if (!broadcastBid)
await req.wallet.sign(auctionTxs.bid, passphrase);
await req.wallet.sign(auctionTXs.bid, passphrase);

await req.wallet.sign(auctionTxs.reveal, passphrase);
await req.wallet.sign(auctionTXs.reveal, passphrase);
}

const jsonBid = auctionTxs.bid.getJSON(this.network);
const jsonReveal = auctionTxs.reveal.getJSON(this.network);
const jsonBid = auctionTXs.bid.getJSON(this.network);
const jsonReveal = auctionTXs.reveal.getJSON(this.network);

if (options.paths) {
await this.addOutputPaths(jsonBid, auctionTxs.bid, req.wallet);
await this.addOutputPaths(jsonReveal, auctionTxs.reveal, req.wallet);
await this.addOutputPaths(jsonBid, auctionTXs.bid, req.wallet);
await this.addOutputPaths(jsonReveal, auctionTXs.reveal, req.wallet);
}

return res.json(200, {
Expand Down
6 changes: 3 additions & 3 deletions lib/wallet/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1897,10 +1897,10 @@ class Wallet extends EventEmitter {
* @returns {MTX} output.reveal
*/

async createAuctionTxs(name, value, lockup, options) {
async createAuctionTXs(name, value, lockup, options) {
const unlock = await this.fundLock.lock();
try {
return await this._createAuctionTxs(name, value, lockup, options);
return await this._createAuctionTXs(name, value, lockup, options);
} finally {
unlock();
}
Expand All @@ -1918,7 +1918,7 @@ class Wallet extends EventEmitter {
* @returns {MTX} output.reveal
*/

async _createAuctionTxs(name, value, lockup, options) {
async _createAuctionTXs(name, value, lockup, options) {
const bid = await this._createBid(name, value, lockup, options);

const bidOuputIndex = bid.outputs.findIndex(o => o.covenant.isBid());
Expand Down
14 changes: 7 additions & 7 deletions lib/wallet/walletdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@ class WalletDB extends EventEmitter {
return null;
}

const walletTxs = [];
const walletTXs = [];
let filterUpdated = false;

try {
Expand All @@ -2459,7 +2459,7 @@ class WalletDB extends EventEmitter {
const txadded = await this._addTX(tx, tip);

if (txadded) {
walletTxs.push(tx);
walletTXs.push(tx);

if (txadded.filterUpdated)
filterUpdated = true;
Expand All @@ -2468,20 +2468,20 @@ class WalletDB extends EventEmitter {

// Sync the state to the new tip.
// If we encountered wallet txs, we also trigger mark check.
await this.setTip(tip, walletTxs.length > 0);
await this.setTip(tip, walletTXs.length > 0);
} finally {
this.confirming = false;
}

if (walletTxs.length > 0) {
if (walletTXs.length > 0) {
this.logger.info('Connected WalletDB block %x (tx=%d).',
tip.hash, walletTxs.length);
tip.hash, walletTXs.length);
}

this.emit('block connect', entry, walletTxs);
this.emit('block connect', entry, walletTXs);

return {
txs: walletTxs.length,
txs: walletTXs.length,
filterUpdated: filterUpdated
};
}
Expand Down
16 changes: 8 additions & 8 deletions test/node-rescan-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ describe('Node Rescan Interactive API', function() {
const {node} = nodeCtx;
const startHeight = nodeCtx.height - RESCAN_DEPTH + 1;

const filterAndTxs = tests.slice();
let test = filterAndTxs.shift();
const filterAndTXs = tests.slice();
let test = filterAndTXs.shift();

// initial run is the first filter test.
let count = 0;
Expand All @@ -304,14 +304,14 @@ describe('Node Rescan Interactive API', function() {
// we are testing against the current filter.
assert(test.txCountCheck(entry.height, txs));

if (filterAndTxs.length === 0) {
if (filterAndTXs.length === 0) {
return {
type: scanActions.ABORT
};
}

// next test
test = filterAndTxs.shift();
test = filterAndTXs.shift();

return {
type: scanActions.REPEAT_SET,
Expand Down Expand Up @@ -710,8 +710,8 @@ describe('Node Rescan Interactive API', function() {
it('should rescan the same block with update filters (REPEAT_SET)', async () => {
const startHeight = nodeCtx.height - RESCAN_DEPTH + 1;

const filterAndTxs = tests.slice();
let test = filterAndTxs.shift();
const filterAndTXs = tests.slice();
let test = filterAndTXs.shift();

let count = 0;

Expand All @@ -723,13 +723,13 @@ describe('Node Rescan Interactive API', function() {
assert.strictEqual(entry.height, startHeight);
assert(test.txCountCheck(entry.height, txs));

if (filterAndTxs.length === 0) {
if (filterAndTXs.length === 0) {
return {
type: scanActions.ABORT
};
}

test = filterAndTxs.shift();
test = filterAndTXs.shift();

return {
type: scanActions.REPEAT_SET,
Expand Down
32 changes: 16 additions & 16 deletions test/wallet-chainstate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ describe('WalletDB ChainState', function() {
await progressWithNoTX(wdb);

for (let i = 0; i < blocksPerAction; i++) {
const blockAndTxs = await progressWithNoTX(wdb);
removeBlocks.push(blockAndTxs);
const blockAndTXs = await progressWithNoTX(wdb);
removeBlocks.push(blockAndTXs);
}

assert.strictEqual(wdb.state.startHeight, 0);
Expand All @@ -277,11 +277,11 @@ describe('WalletDB ChainState', function() {
assert.strictEqual(wdb.state.marked, false);

for (let i = 0; i < blocksPerAction; i++) {
const blockAndTxs = await progressWithTX(wdb);
removeBlocks.push(blockAndTxs);
const blockAndTXs = await progressWithTX(wdb);
removeBlocks.push(blockAndTXs);

if (!firstBlock)
firstBlock = blockAndTxs.block;
firstBlock = blockAndTXs.block;

assert.strictEqual(wdb.state.startHeight, firstBlock.height);
assert.bufferEqual(wdb.state.startHash, firstBlock.hash);
Expand Down Expand Up @@ -389,10 +389,10 @@ describe('WalletDB ChainState', function() {
removeBlocks.push(await progressWithNoTX(wdb));

for (let i = 0; i < blocksPerAction; i++) {
const blockAndTxs = await progressWithTX(wdb);
const blockAndTXs = await progressWithTX(wdb);
if (!firstBlock)
firstBlock = blockAndTxs.block;
removeBlocks.push(blockAndTxs);
firstBlock = blockAndTXs.block;
removeBlocks.push(blockAndTXs);
}

assert.strictEqual(wdb.state.startHeight, firstBlock.height);
Expand All @@ -416,10 +416,10 @@ describe('WalletDB ChainState', function() {
firstBlock = null;

for (let i = 0; i < blocksPerAction; i++) {
const blockAndTxs = await progressWithTX(wdb);
const blockAndTXs = await progressWithTX(wdb);

if (!firstBlock)
firstBlock = blockAndTxs.block;
firstBlock = blockAndTXs.block;

assert.strictEqual(wdb.state.startHeight, firstBlock.height);
assert.strictEqual(wdb.state.startHash, firstBlock.hash);
Expand All @@ -445,10 +445,10 @@ describe('WalletDB ChainState', function() {
await progressWithNoTX(wdb);

for (let i = 0; i < blocksPerAction * 2; i++) {
const blockAndTxs = await progressWithTX(wdb);
const blockAndTXs = await progressWithTX(wdb);
if (!firstBlock)
firstBlock = blockAndTxs.block;
removeBlocks.push(blockAndTxs);
firstBlock = blockAndTXs.block;
removeBlocks.push(blockAndTXs);
}

assert.strictEqual(wdb.state.startHeight, firstBlock.height);
Expand Down Expand Up @@ -487,10 +487,10 @@ describe('WalletDB ChainState', function() {
firstBlock = null;

for (let i = 0; i < blocksPerAction; i++) {
const blockAndTxs = await progressWithTX(wdb);
const blockAndTXs = await progressWithTX(wdb);
if (!firstBlock)
firstBlock = blockAndTxs.block;
removeBlocks.push(blockAndTxs);
firstBlock = blockAndTXs.block;
removeBlocks.push(blockAndTXs);

assert.strictEqual(wdb.state.startHeight, firstBlock.height);
assert.strictEqual(wdb.state.startHash, firstBlock.hash);
Expand Down
8 changes: 4 additions & 4 deletions test/wallet-http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ describe('Wallet HTTP', function() {
const bidValue = 1000000;
const lockupValue = 5000000;

const auctionTxs = await wallet.client.post(
const auctionTXs = await wallet.client.post(
`/wallet/${wallet.id}/auction`,
{
name: name,
Expand All @@ -1204,7 +1204,7 @@ describe('Wallet HTTP', function() {

let walletAuction = await wallet.getAuctionByName(name);
const bidFromWallet = walletAuction.bids.find(
b => b.prevout.hash === auctionTxs.bid.hash
b => b.prevout.hash === auctionTXs.bid.hash
);
assert(bidFromWallet);

Expand All @@ -1216,15 +1216,15 @@ describe('Wallet HTTP', function() {
assert.equal(b5.lockedConfirmed - lockConfirmedBeforeTest, lockupValue);
assert.equal(b5.lockedUnconfirmed - lockUnconfirmedBeforeTest, lockupValue);

await nclient.broadcast(auctionTxs.reveal.hex);
await nclient.broadcast(auctionTXs.reveal.hex);
await nodeCtx.mineBlocks(1, cbAddress);

// Confirmed REVEAL with highest bid makes wallet the owner
ownedNames.push(name);

walletAuction = await wallet.getAuctionByName(name);
const revealFromWallet = walletAuction.reveals.find(
b => b.prevout.hash === auctionTxs.reveal.hash
b => b.prevout.hash === auctionTXs.reveal.hash
);
assert(revealFromWallet);

Expand Down
6 changes: 3 additions & 3 deletions test/wallet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3300,11 +3300,11 @@ describe('Wallet', function() {
assert.strictEqual(bal.ulocked, lockup);
assert.strictEqual(bal.clocked, lockup);

const auctionsTxs = await wallet.createAuctionTxs(name, value, lockup, {
const auctionsTXs = await wallet.createAuctionTXs(name, value, lockup, {
hardFee: fee
});
const winningBidUnsent = auctionsTxs.bid;
unsentReveal = auctionsTxs.reveal;
const winningBidUnsent = auctionsTXs.bid;
unsentReveal = auctionsTXs.reveal;

const winningBid = await wallet.sendMTX(winningBidUnsent, null);
uTXCount++;
Expand Down

0 comments on commit d754b86

Please sign in to comment.