Tap asset services
Tap asset services give the application one way to work with Taproot Assets across supported node types. They connect store actions to Tapd RPC calls through the desktop process and turn node data into shared asset, balance, address, transfer, and Universe views. For the wider service pattern, see Service client architecture; for the related Lightning flows, see Lightning service capabilities.
Service abstraction
The service abstraction separates asset actions from the node access method. Store code asks for a TapService and receives shared application data instead of handling Tapd RPC response shapes or desktop transport details.
Node service selection
The TapFactory is the entry point for asset services. It maps both tapd nodes and litd nodes to the Tapd-backed service, because a litd node exposes the Tapd capability through its associated asset service. The service rejects other node implementations rather than sending an invalid request.
The shared service contract covers node readiness, asset and balance queries, address work, minting, transfers, Universe data, and asset-aware channel operations. This contract lets the store keep the same workflow when another asset service is added later.
References: src/…/tapFactory.ts• L5-29 src/…/index.ts• L214-258 src/…/tapdService.ts• L213-218
Tapd RPC boundary
The Tapd proxy client carries service requests across the Electron IPC boundary. In the main process, the proxy server creates or reuses a Tapd RPC client for each network node and calls the matching Tapd area for assets, minting, Universe, or channels.
The boundary also makes RPC data safe for the application layer. It fills response fields that Tapd leaves out when their values are empty and changes byte arrays to hex strings. The service then maps these normalized responses to small shared types such as TapAsset, TapBalance, and TapAddress.
The request path is therefore:
flowchart LR
Store[Store action] --> Factory[TapFactory]
Factory --> Service[TapdService]
Service --> Client[Tapd proxy client]
Client --> IPC[Electron IPC]
IPC --> Server[Tapd proxy server]
Server --> RPC[Tapd RPC]
RPC --> Server --> IPC --> Client --> Service --> Store
References: src/…/tapdProxyClient.ts• L6-88 electron/…/tapdProxyServer.ts• L15-38 electron/…/tapdProxyServer.ts• L167-227 src/…/tapdDefaults.ts• L13-29 src/…/tapdDefaults.ts• L117-149 src/…/types.ts• L5-48
Asset and balance views
The Tap model stores the latest asset data per Tap node and derives network-wide views from it. The data supports both on-chain asset ownership and assets held in Lightning channels, so screens can use one asset identity across those locations.
Asset inventory
Asset inventory describes what a node knows about an asset. Each shared asset record includes its identity, name, kind, amount, decimal display, group key, and chain anchor information. A normal asset can be held on chain or in a channel; a collectible is represented as a distinct asset kind.
The model merges on-chain assets from Tap nodes with normal assets reported by Lightning channels. It keys the result by asset ID. This gives the application a single lookup for labels and decimal conversion even when the same asset appears in more than one part of the network.
References: src/…/types.ts• L5-14 src/…/tap.ts• L25-33 src/…/tap.ts• L146-177 src/…/tapdService.ts• L71-89
Balance and Universe roots
Balances show the amount that a Tap node controls for each asset. Universe roots show the root amount known for an asset in the Tap Universe, where a Universe is the shared proof and metadata source for asset history. The model keeps these views per node and also provides a de-duplicated network-wide root list.
The service requests balances by asset ID and converts the nested Tapd result into records with the asset name, kind, balance, and genesis point. It requests Universe roots with amounts and exposes each asset ID and root sum as a simple record. Asset amounts remain integer values at this boundary; the model applies decimal display only when it formats a value for a user.
References: src/…/tapdService.ts• L91-122 src/…/types.ts• L16-23 src/…/tap.ts• L135-145 src/…/tap.ts• L187-218 src/…/tap.ts• L219-239
Asset lifecycle
The store coordinates the asset lifecycle around the service contract. It adds local checks and network actions where an asset operation also needs Bitcoin funds, confirmation, or a fresh view of node state.
Address management
An asset address identifies an asset and the amount that a recipient can receive. The service creates an address from an asset ID and amount, and it decodes an address back into its asset identity and encoded key data.
The store enriches decoded addresses with the local asset name and formats the amount with the asset's decimal setting. This makes address validation and send forms readable without changing the encoded address exchanged with Tapd.
References: src/…/index.ts• L223-232 src/…/tapdService.ts• L11-26 src/…/tapdService.ts• L39-58 src/…/tap.ts• L310-314 src/…/tap.ts• L366-381
Asset minting
Minting creates a new asset in a pending batch and can then finalize that batch on chain. The store supports normal and collectible assets, optional grouped issuance, decimal display, and an option to finalize the batch as part of the same action.
When auto-funding is enabled for a Tapd-backed node, the store first gives its linked Lightning node Bitcoin funds for the operation. After finalization, it asks the Bitcoin service to mine enough blocks for confirmation. The mint action returns the Tapd mint result while the network refresh follows the normal block and asset update paths.
References: src/…/tap.ts• L35-44 src/…/tap.ts• L240-301 src/…/tapdService.ts• L60-69 src/…/tapdDefaults.ts• L31-56
Asset transfers
Sending an asset consumes an asset address and produces a transfer receipt with the anchor transaction ID. The store can auto-fund the linked Lightning node before the send, then mines confirmation blocks and refreshes the node's asset data.
The balance refresh is not assumed to be immediate. After the send, the store decodes the destination address to identify the asset and checks the balance again for a short period. This keeps the displayed balance aligned with the transfer once Tapd has processed it.
References: src/…/index.ts• L224-231 src/…/tapdService.ts• L28-37 src/…/tap.ts• L315-364 src/…/tapdDefaults.ts• L74-93
Tap Universe synchronization
Tap Universe synchronization imports asset proof and metadata knowledge from a named Universe host into a node. The service returns the set of Universes that it synchronized, while the store reloads the node's assets, balances, and roots so the new knowledge is visible to the rest of the application.
The same synchronization step supports asset channel setup. Before a node funds an asset channel, the store synchronizes the receiving node from the sending node's host. This helps both ends recognize the asset before the channel operation starts.
The synchronization flow is:
sequenceDiagram
participant Store as Tap model
participant Service as Tapd service
participant Universe as Tap Universe
participant View as Asset state
Store->>Service: syncUniverse(node, host)
Service->>Universe: synchronize proofs and metadata
Universe-->>Service: synchronized Universe list
Service-->>Store: sync result
Store->>Service: reload assets, balances, and roots
Service-->>View: refreshed node data
References: src/…/tapdService.ts• L109-126 src/…/tap.ts• L303-309 src/…/tap.ts• L383-422 src/…/tapdProxyClient.ts• L53-66 electron/…/tapdProxyServer.ts• L96-115
Channel asset operations
Tap asset services also bridge on-chain assets to Taproot Asset channels. They fund a channel with an asset and use asset invoices for off-chain payments, while Lightning services continue to provide node identity and invoice decoding.
Channel funding
Channel funding moves an asset amount from one Tap node to a Lightning peer. The store checks the sender's known asset balance, obtains the peer public key, synchronizes the peer's Universe view, and then asks Tapd to fund the channel.
Bitcoin confirmation is part of the user-visible operation. The store mines confirmation blocks, waits for node processing, and synchronizes the network chart after the channel is established.
References: src/…/index.ts• L234-239 src/…/tapdService.ts• L128-146 src/…/tap.ts• L383-422
Asset invoices and payments
An asset invoice turns an amount held in a channel into a payment request. The store checks that the node has enough channel assets, asks Tapd to create the invoice, and uses the Lightning service to decode its Bitcoin amount for the caller.
Paying an asset invoice follows the reverse path. The store checks channel holdings, decodes the invoice to set a fee limit, and asks Tapd to send the payment through the selected peer. Tapd reports the payment result through a stream; the service exposes a common payment receipt with the asset amount and preimage. The store then refreshes the network chart.
References: src/…/index.ts• L240-253 src/…/tapdService.ts• L148-193 src/…/lit.ts• L117-183 electron/…/tapdProxyServer.ts• L125-165
Network refresh
Asset data is refreshed at two important times: when a Tap node becomes ready and when Bitcoin mining changes the network. Readiness checks use a repeated asset query, so the node is marked started only after its Tapd service responds.
After a mined block, the model waits for Lightning nodes and then reloads assets, balances, and Universe roots for started Tap nodes. It also includes litd Lightning nodes by mapping them to their Tapd view. A failed refresh is reported for the affected node without stopping refreshes for the other nodes.
References: src/…/tapdService.ts• L195-211 src/…/network.ts• L920-930 src/…/tap.ts• L424-448
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the
TapServicecontract,TapFactoryimplementation map, and every store call aligned when a node implementation or asset operation changes. - Keep the IPC channel names, proxy client methods, and main-process listener map aligned. A mismatch fails across the process boundary rather than at the call site.
- Preserve the shared asset and address fields when changing Tapd response mapping. Decimal display and asset-ID lookup depend on those fields.
- If mint or send confirmation behavior changes, review the linked Lightning funding and Bitcoin mining steps as one user operation.
- If Universe synchronization changes, review both the post-sync asset refresh and the pre-channel-funding synchronization.
- If Tapd response shapes change, update the default-value and byte-to-hex normalization rules with the service mapping.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A non-tapd or non-litd node reaches TapdService | The asset request is rejected before an invalid RPC call | TapdService checks the node implementation and TapFactory maps only supported implementations. |
| Tapd is not ready or its RPC access data is invalid | Startup or a later asset refresh reports that node as unavailable | Readiness polling waits for a successful asset query. The proxy builds the client from the node's RPC port and credential paths. |
| A mint batch is not finalized | The asset remains pending and is not confirmed on chain | Treat mint creation and batch finalization as separate stages. Use the finalize option when the workflow needs a confirmed asset. |
| A channel funding amount exceeds the sender's known balance | Channel funding stops with a capacity error | The store checks the current asset balance before it asks Tapd to fund the channel. |
| A payment stream ends without a final result or reports failure | The payment action rejects instead of returning a false success | The proxy resolves only a successful terminal payment result and rejects failed or incomplete streams. |
Key files
| File | Why to read it |
|---|---|
| src/…/tap.ts | Shows the product-level asset lifecycle, state refresh rules, mint and send coordination, Universe sync, and channel funding. |
| src/…/index.ts | Defines the service contract used by store actions and the factory injection. |
| src/…/tapFactory.ts | Shows how node implementations select the asset service. |
| src/…/tapdService.ts | Shows the shared shape returned by the Tapd-backed service. |
| src/…/tapdProxyClient.ts | Shows the client-side request surface at the process boundary. |
| electron/…/tapdProxyServer.ts | Shows how IPC requests reach Tapd RPC and how responses and payment streams become application results. |
| src/…/types.ts | Defines the compact asset, balance, address, transfer, and Universe-root records used above the RPC layer. |
| src/…/tapdDefaults.ts | Explains how omitted Tapd fields receive safe defaults and binary values become transport-safe strings. |
| src/…/lit.ts | Shows how asset invoices and payments use both Tapd and Lightning services. |