Skip to content

txnbuild: CreateClaimableBalance.Validate() accepts empty Destinations #6007

Open

Description

@yigitcangokmen

Bug

CreateClaimableBalance.Validate() returns nil when Destinations is nil or an empty slice. stellar-core rejects such operations with CREATE_CLAIMABLE_BALANCE_MALFORMED (the doCheckValid guard checks claimants.empty()), so the SDK should catch this at build time.

Reproduce

op := &txnbuild.CreateClaimableBalance{
    Amount: "10.0000000",
    Asset:  txnbuild.NativeAsset{},
    // Destinations intentionally omitted
}
err := op.Validate()
fmt.Println(err) // <nil>  -- should be a validation error

Root cause

The for _, d := range cb.Destinations loop in Validate() is a no-op when the slice is nil or empty, so the method falls through to the amount/asset checks and returns nil.

Note

js-stellar-base already validates this:

if (!Array.isArray(opts.claimants) || opts.claimants.length === 0) {
  throw new Error('must provide at least one claimant');
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions