hyperledger / hyperledger/fabric-x

fxconfig: TxID is lost when using --wait on namespace create/update

Open
#197 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
64
Forks
80
Avg merge
1d 22h
Merged PRs (30d)
15

Description

## Summary

When running `fxconfig namespace create` or `fxconfig namespace update` with
`--endorse --submit --wait`, the Transaction ID (TxID) is silently discarded.
The user only sees a status message with no way to reference the transaction later.

## What happens

After `--wait`, the CLI prints:
Transaction status: COMMITTED

But the TxID is never shown. Without it, users have no way to track or audit
which transaction was submitted.

## What should happen
Transaction ID:
Transaction status: COMMITTED

## Root cause

In `tools/fxconfig/internal/app/deploy.go`, the `DeployNamespace` function
has the TxID available in `out.TxID` but explicitly discards it before returning:

```go
if input.Wait {
status, err := d.SubmitTransactionWithWait(ctx, out.TxID, out.Tx)
if err != nil {
return nil, UnknownStatus, err
}
return nil, status, nil // out.TxID is lost here
}
```

The same happens for the submit-without-wait path:

```go
if err := d.SubmitTransaction(ctx, out.TxID, out.Tx); err != nil {
return nil, UnknownStatus, err
}
return nil, UnknownStatus, nil // TxID lost here too
```

Because `res` comes back as `nil`, the CLI handlers in `namespace_create.go`
and `namespace_update.go` only print the status and skip the TxID entirely.

Compare this to running without `--wait` — the full transaction JSON including
TxID is printed. So the TxID is only visible when you don't actually submit.

## Proposed fix

In `deploy.go`, return the TxID even when submitting:

```go
return &DeployNamespaceOutput{TxID: out.TxID}, status, nil
```

Then update the CLI handlers in `namespace_create.go` and `namespace_update.go`
to print the TxID alongside the status:

```go
if res != nil && res.TxID != "" {
ctx.Printer.Print(fmt.Sprintf("Transaction ID: %s", res.TxID))
}
ctx.Printer.Print(fmt.Sprintf("Transaction status: %s", committerpb.Status_name[int32(status)]))
```

## Files affected

- `tools/fxconfig/internal/app/deploy.go`
- `tools/fxconfig/internal/cli/v1/namespace_create.go`
- `tools/fxconfig/internal/cli/v1/namespace_update.go`

## Additional notes

I verified this by reading the source directly. Happy to submit a PR with the fix.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.