handshake-org / handshake-org/hsd

Wallet Events for Auction Related Transactions

Open
#193 0 comments 1 reaction 0 assignees View on GitHub
wallet wallet-api
Dominant language
JavaScript
Stars
2.1k
Forks
306
PR merge metrics
No merged PRs in 30d

Description

It would be useful if the wallet emitted specific events for auction related transactions. There are multiple locations in the codebase where this functionality can be added.

---

It is possible to implement this in `txdb.insert`. This code path emits events already, in particular a `tx` event. It makes sense to emit auction related events right after the `tx` event because the wallet is certain that it received a transaction by this point in the codepath so it can be certain of auction related outputs inside of the transaction. The implementation could look at each of the outputs on the `tx` and emit based on the covenant type.

```javascript
this.emit('tx', tx, details);
this.emit('balance', balance);
```

I think that this is the best place to implement this functionality.

https://github.com/handshake-org/hsd/blob/master/lib/wallet/txdb.js#L1065

---

`Wallet.add` already emits an `address` event, the auction related events could be emitted inside of the `if (details)` block.

```javascript
async _add(tx, block) {
const details = await this.txdb.add(tx, block);

if (details) {
const derived = await this.syncOutputDepth(tx);
if (derived.length > 0) {
this.wdb.emit('address', this, derived);
this.emit('address', derived);
}
}

return details;
}
```

https://github.com/handshake-org/hsd/blob/master/lib/wallet/wallet.js#L3842-L3854

Contributor guide

Open the contributing guide

Research direction

Start by reading lib/wallet/txdb.js around txdb.insert at line 1065 and lib/wallet/wallet.js around _add at lines 3842-3854. Trace the existing tx and address event flows and identify the auction-related covenant outputs and event names expected by the wallet. Done means auction transaction events are emitted at the appropriate point without disrupting existing events.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.