Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get bound xUDT balance by btc address #133

Closed
Flouse opened this issue May 13, 2024 · 3 comments · Fixed by #146 or #155
Closed

Get bound xUDT balance by btc address #133

Flouse opened this issue May 13, 2024 · 3 comments · Fixed by #146 or #155
Assignees
Labels
enhancement New feature or request P-Medium

Comments

@Flouse
Copy link
Contributor

Flouse commented May 13, 2024

To get the bound xUDT balance by a BTC address in the RGB++ Assets API

Get /rgbpp/v1/address/{btc_address}/balance (Draft)

Parameters

  • xUDT type_script
  • btc_address

The response format will likely contain the confirmed and unconfirmed bound xUDT balance for the specified BTC address.

{
  "confirmed_balance": "1234",
  "unconfirmed_balance": "567"
}

requested by JoyID team @shaojunda

Related API

@Flouse Flouse added enhancement New feature or request P-Low labels May 13, 2024
@Flouse Flouse added P-Medium and removed P-Low labels May 21, 2024
@Flouse Flouse changed the title [Discussion] Get bound xUDT balance by btc address Get bound xUDT balance by btc address May 21, 2024
@ahonn
Copy link
Collaborator

ahonn commented May 21, 2024

I'm not sure we can calculate the unconfirmed balance using the bounded cells. I will investigate this later.
The balance of the BTC address may have more than one token, so I think the API response data should be an array.
e.g.

z.array(
  z.object({
    name: z.string(),
    decimal: z.number(),
    symbol: z.string(),
    amount: z.string(),
  }),
)

@ahonn
Copy link
Collaborator

ahonn commented May 21, 2024

I just submitted a draft PR for this feature. After investigating, I discovered that the unique cell symbol can be duplicated, so I included the typeHash field to distinguish the tokens with the same symbol.

@Flouse
Copy link
Contributor Author

Flouse commented May 27, 2024

calculate the unconfirmed balance using the bounded cells

  1. Let's say BTC_UTXO_A is unconfirmed
  2. Get the txid_A of BTC_UTXO_A
  3. search the job in RGB++ transaction queue by txid_A
  4. If job_A is found and job_A's ckbVirtualTx contains one or more xUDT cells bound to BTC_UTXO_A, then the unconfirmed balance can be calculated by the sum of the bounded xUDT data.

@Flouse Flouse reopened this May 28, 2024
@Flouse Flouse linked a pull request May 28, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P-Medium
Projects
None yet
2 participants