Proper Balance Calculation Using Origin

In certain circumstances, it is possible for a user to connect what look like separate accounts, but they are actually nested inside each other. 

For example, in Bitcoin, an XPUB (Extended Public Key) is a master key that can generate multiple Bitcoin addresses for receiving payments. This allows a user to hold funds more securely in multiple addresses to spread out potential attack vectors. When connecting an XPUB, we scan the possible addresses that can be derived from that XPUB to construct a total balance. A user can also attach a single address as an account if they want to show only a certain part of their total digital asset balance. In this scenario, there may be an overlap of accounts. 


To account for this, we have added an origin property. This field is helpful If your application needs to view an Account Holder’s balances without duplicates or potential overlaps.

Example Scenario:

  1. Account Holder Alice ( ah_A ) connects her XPUB Account ( acc_A ), which contains multiple Records ( rec_A0, rec_A1, ..., rec_An). The first Record ( rec_A0 ) has an origin value of origin_0.

  2. Alice then connects an individual address Account ( acc_B ), which is part of the previously connected XPUB ( acc_A ). This results in a new Record ( rec_B0) with the same origin as the XPUB’s first Record ( origin_0 ).

You can use the origin when constructing total balances to exclude duplicates. If two records have the same origin, one can be excluded. 

Important Considerations:

  • Records are not merged. Each record represents an individual connection made by an Account Holder to your organization. This means that Records have their own permissions and must be disconnected or reconnected individually.

  • If a different Account Holder connects to the same address, the Record will have a different origin, ie origin’s are not the same across users. An origin is unique within accounts connected by an individual Account Holder. 

    • For example:

      • If Alice connects an address A, it will have origin_a.

      • If her husband Bob also connects address A on his account, that will have a different origin_b. They will not be the same.

Using the origin field helps ensure you maintain a clear and duplicate-free view of a single Account Holder's balances.