Skip to content

Inconsistent claimable balance ID format handling across commands #2451

@leighmcculloch

Description

@leighmcculloch

What version are you using?

main (commit 8a6c883)

What did you do?

Tried to use claim-claimable-balance with the 72-char hex format (returned by Horizon API) and the strkey format (returned by getTransaction) using a real testnet claimable balance (00000000fa8e1bed9deeb6ae75441056b18bcfbde917eca581f70cb93cca637ee10bfa85):

# 72-char hex with type prefix (Horizon API format) - FAILS
stellar tx new claim-claimable-balance \
  --balance-id 00000000fa8e1bed9deeb6ae75441056b18bcfbde917eca581f70cb93cca637ee10bfa85

# Strkey format (returned by getTransaction) - FAILS
stellar tx new claim-claimable-balance \
  --balance-id BAAAAAAA7KHBX3M5523K45KECBLLDC6PXXURP3FFQH3QZOJ4ZJRX5YIL7KCZJ4I

The same formats work with clawback-claimable-balance:

# 72-char hex - WORKS
stellar tx new clawback-claimable-balance \
  --balance-id 00000000fa8e1bed9deeb6ae75441056b18bcfbde917eca581f70cb93cca637ee10bfa85

# Strkey - WORKS
stellar tx new clawback-claimable-balance \
  --balance-id BAAAAAAA7KHBX3M5523K45KECBLLDC6PXXURP3FFQH3QZOJ4ZJRX5YIL7KCZJ4I

ledger entry fetch claimable-balance --id also only accepts hex, not strkey.

What did you expect to see?

All commands that accept a --balance-id should accept all three common formats consistently:

Format Example
64-char hex (hash only) fa8e1bed9deeb6ae75441056b18bcfbde917eca581f70cb93cca637ee10bfa85
72-char hex (with 00000000 type prefix, Horizon API) 00000000fa8e1bed9deeb6ae75441056b18bcfbde917eca581f70cb93cca637ee10bfa85
Strkey (B..., returned by getTransaction) BAAAAAAA7KHBX3M5523K45KECBLLDC6PXXURP3FFQH3QZOJ4ZJRX5YIL7KCZJ4I

clawback-claimable-balance already does this correctly via its parse_balance_id function.

What did you see instead?

claim-claimable-balance rejects both the 72-char hex and strkey formats with an invalid hex error, because it only does a raw hex::decode and validates the result is exactly 32 bytes (claim_claimable_balance.rs:30-41).

ledger entry fetch claimable-balance also rejects strkey format because it uses padded_hex_from_str which only handles hex (claimable_balance.rs:39).

The fix is to reuse the existing parse_balance_id from clawback_claimable_balance.rs:49-88 (or move it to a shared utility) in claim-claimable-balance and ledger entry fetch claimable-balance.

Command 64-char hex 72-char hex Strkey
tx new claim-claimable-balance works fails fails
tx new clawback-claimable-balance works works works
ledger entry fetch claimable-balance works fails fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog (Not Ready)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions