Skip to content

Fix sendrawtransaction to return txid string and validate synchronously#35

Merged
ordishs merged 20 commits into
bsv-blockchain:mainfrom
shruggr:fix/33-sendrawtransaction
Oct 29, 2025
Merged

Fix sendrawtransaction to return txid string and validate synchronously#35
ordishs merged 20 commits into
bsv-blockchain:mainfrom
shruggr:fix/33-sendrawtransaction

Conversation

@shruggr

@shruggr shruggr commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Summary

Fix sendrawtransaction to return transaction ID as a string and validate synchronously per Bitcoin RPC specification.

Changes

  • Return txid string instead of ResponseWrapper array (fixes client JSON unmarshal errors)
  • Implement synchronous validation by calling validator directly
  • Store transaction in blob store before validation
  • Only return success after validation completes

Related Issues

Fixes #33

Changes sendrawtransaction RPC handler to return transaction ID as a string
instead of ResponseWrapper array. Adds synchronous validation by calling
validator service directly before returning, ensuring invalid transactions
are rejected immediately per Bitcoin RPC spec.
@shruggr

shruggr commented Oct 22, 2025

Copy link
Copy Markdown
Contributor Author

I have two more tests coming momentarily to fix the inadequate coverage.

@github-actions

github-actions Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Status: Complete


Current Review:

The implementation correctly validates transactions synchronously and returns the txid as a string, which fixes the original issues in #33. The approach of calling validator.Validate directly mirrors the propagation service's synchronous path when Kafka is not configured (propagation/Server.go:950).

Key observations:

  • Blob storage before validation follows the propagation service pattern (propagation/Server.go:930)
  • blockHeight = 0 correctly tells the validator to use current height from UTXO store (Validator.go:380-383)
  • Validator handles UTXO spending, creation, and sends to block assembly (Validator.go:552, 593)
  • Tests verify proper error handling for blob storage, validation failures, and success cases

The author noted one concern still needs addressing. Human reviewers should evaluate whether the current approach meets all requirements for transaction propagation in production deployments.

Comment thread services/rpc/handlers.go
Comment thread services/rpc/handlers.go
Comment thread services/rpc/handlers.go
oskarszoon and others added 3 commits October 22, 2025 17:10
This updates the RPC service to use the propagation service client
directly instead of going through the Distributor, addressing issue bsv-blockchain#33.

Changes:
- Extract propagation.Client interface for testability
- Update RPC Server to accept propagation client
- Modify sendrawtransaction handler to use propagation client
- Update all RPC tests to work with new propagation client mock

This takes direction from issue bsv-blockchain#22 but does not fully implement it yet.

Fixes bsv-blockchain#33
…tion

The RPC service now creates its own propagation client internally,
so it no longer needs txStore and validatorClient passed in from daemon.
Comment thread services/rpc/handlers.go Outdated
@shruggr

shruggr commented Oct 23, 2025

Copy link
Copy Markdown
Contributor Author

I have reverted my last commit to this which used the propagation client as it does not support synchronous validation.

Instead, I am storing the transaction and then calling the validator. This flow is copied from the non-kafka flow in ProcessTransaction within propagation server.

@ordishs ordishs self-requested a review October 29, 2025 15:07
@sonarqubecloud

Copy link
Copy Markdown

@ordishs ordishs merged commit 9fd1869 into bsv-blockchain:main Oct 29, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sendrawtransaction returns array instead of txid string

3 participants