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

feat: add rgbpp address activity api #182

Merged
merged 10 commits into from
Jul 10, 2024
Merged

feat: add rgbpp address activity api #182

merged 10 commits into from
Jul 10, 2024

Conversation

ahonn
Copy link
Collaborator

@ahonn ahonn commented Jun 24, 2024

Changes

  • Optimize /rgbpp/v1/transaction/:btc_txid query RGB++ CKB txhash by batching requests
  • Add new activity API: /rgbpp/v1/address/:btc_address/activity for query RGB++ transaction (includes BTC Tx and isomorphic(CKB) Tx.
    • query parameters
      • type_script: same as other API, pass type script to filter transaction
      • rgbpp_only : only RGB++ related transactions are returned
      • after_btc_txid: As a paging parameter, pass as the cursor (get the cursor in the response by the previous request)
    • response (See the definition of the interface below)
      • For normal BTC transactions
        • Only return btcTx and isRgbpp=false (Rgb++ transactions sent by other services also return this before the block is confirmed)
      • For RGB++ transaction
        • Always return isomorphicTx.inputs, isomorphicTx.outputs and one of isomorphicTx.CKBRawTx and isomorphicTx.CkbTx
        • For unconfirmed RGB++ transaction
          • Return isomorphicTx.ckbRawTx with isomorphicTx.status.confirmed = false if RGB++ isomorphic(CKB) tx not sent
          • Return isomorphicTx.ckbTx with isomorphicTx.status.confirmed = false if RGB++ isomorphic(CKB) tx have sent
        • For confirmed RGB++ transaction
          • Return isomorphicTx.ckbTx with isomorphicTx.status.confirmed = true

Interface

// /rgbpp/v1/address/:btc_address/activity

// query params
{
  type_script: string 
  rgbpp_only?: false 
  after_btc_txid?: string  // page cursor
}

// response
const response = z.object({
    address: z.string(),
    txs: z.array(
      z.object({
        btcTx: BTCTransaction,
        isRgbpp: z.boolean(),
        isomorphicTx: IsomorphicTransaction.optional(),
      }),
    ),
   cursor: z.string().optional(),
  }),
};

const IsomorphicTransaction = z.object({
  ckbRawTx: CKBRawTransaction.optional(),
  ckbTx: CKBTransaction.optional(),
  inputs: z.array(OutputCell).optional(),
  outputs: z.array(OutputCell).optional(),
  status: z.object({
    confirmed: z.boolean(),
  }),
});

// Is bitcoin tx confirmed?
response.txs[].btcTx.status.confirmed
// Is isomorphic ckb tx confirmed?
response.txs[].isomorphicTx.status.confirmed

Notes

  • The call to queryBtcTimeLockTxByBtcTxId cost for 70% of the total response time
    • use scriptSearchMode: partial may help, but testnet CKB node unsupport for now
   {"code":-1200,"message":"Indexer: Invalid params the CKB indexer doesn't support search_key.script_search_mode partial search mode, please use the CKB rich-indexer for such search"}

Copy link

vercel bot commented Jun 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
btc-assets-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2024 1:11am

@ahonn ahonn merged commit 8e11561 into develop Jul 10, 2024
4 checks passed
@Dawn-githup
Copy link
Collaborator

Dawn-githup commented Jul 12, 2024

Asset API Activity Verification

1. Obtain transaction history successfully (pure BTC transaction)

  • [x]

Test description: The user address only has BTC transactions, and the transaction history is obtained successfully.

Expected response: L2 -> L1 is no op return

2. Obtaining transaction history successfully (RGB++ transaction has no CKB transaction information)

  • [x]

Test description: The user address has RGB++ transactions, but no associated CKB transaction information.

3. Obtaining transaction history successfully (BTC transaction unconfirmed)

Test description: The user address has RGB++ transactions, and the associated BTC transactions are not confirmed.

4. Obtaining transaction history successfully (BTC transaction confirmed, CKB transaction unconfirmed)

  • [x]

Test description: The user address has an RGB++ transaction, and the associated BTC transaction is confirmed, but the CKB transaction is not confirmed.

  1. Obtaining transaction history successfully (BTC/CKB transactions are all confirmed)
  • [x]

Test description: The user address has RGB++ transactions, and the associated BTC and CKB transactions have been confirmed.

6. Get transaction history in pages (via after_btc_txid)

  • [x]

7. Filter transactions by type_script

  • [x]

Test Description: Filter transaction history based on type_script.

8. Filter by after_btc_txid

  • [x]

Exception testing

1. Invalid address format

  • [x]

Test Description: Requesting transaction history using an invalid address format.

2. Address does not exist

  • [x]

Test description: Request the transaction history of a non-existent address.

3. Invalid type_script argument

  • [x]

Test description: Requesting transaction history with invalid type_script parameter.

4. after_btc_txid is invalid

  • [x]
{
  "message": "after_txid not found"
}

@Flouse
Copy link
Contributor

Flouse commented Jul 18, 2024

@Dawn-githup
Copy link
Collaborator

Dawn-githup commented Aug 22, 2024

Asset API Activity Verification

1. Obtain transaction history successfully (pure BTC transaction)

  • [x]

Test description: The user address only has BTC transactions, and the transaction history is obtained successfully.

Expected response: L2 -> L1 is no op return

2. Obtaining transaction history successfully (RGB++ transaction has no CKB transaction information)

  • [x]

Test description: The user address has RGB++ transactions, but no associated CKB transaction information.

3. Obtaining transaction history successfully (BTC transaction unconfirmed)

Test description: The user address has RGB++ transactions, and the associated BTC transactions are not confirmed.

4. Obtaining transaction history successfully (BTC transaction confirmed, CKB transaction unconfirmed)

  • [x]

Test description: The user address has an RGB++ transaction, and the associated BTC transaction is confirmed, but the CKB transaction is not confirmed.

  1. Obtaining transaction history successfully (BTC/CKB transactions are all confirmed)
  • [x]

Test description: The user address has RGB++ transactions, and the associated BTC and CKB transactions have been confirmed.

6. Get transaction history in pages (via after_btc_txid)

  • [x]

7. Filter transactions by type_script

  • [x]

Test Description: Filter transaction history based on type_script.

8. Filter by after_btc_txid

  • [x]

Exception testing

1. Invalid address format

  • [x]

Test Description: Requesting transaction history using an invalid address format.

2. Address does not exist

  • [x]

Test description: Request the transaction history of a non-existent address.

3. Invalid type_script argument

  • [x]

Test description: Requesting transaction history with invalid type_script parameter.

4. after_btc_txid is invalid

  • [x]
{
  "message": "after_txid not found"
}
  • Query and Verify L1-L1, L1-L2 Transactions

  • Query L1-L1 transactions.

  • Query L1-L2 transactions.

  • Query and Verify L1-L1/L2-L1 Multi-Bound UTXO Transactions

  • Generate new UTXO's L1-L1 transaction.

  • Transfer assets to the same UTXO's L2-L1 transaction.

  • Query Transactions with Multiple Cells Bound to an Address
    image

  • Query launch-rgbpp Transaction (This transaction belongs to L2 → L1 and can be queried) cc @ShookLyngs

  • Transaction Link

  • Query distribute-rgbpp Transaction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants