bitcoin / bitcoin

Bitcoin Core integration/staging tree
https://bitcoincore.org/en/download
MIT License
78.99k stars 36.27k forks source link

Support transaction broadcast in REST interface #31017

Open RCasatta opened 2 weeks ago

RCasatta commented 2 weeks ago

Please describe the feature you'd like to see added.

I would like to have the possibility to broadcast a transaction via the REST interface which is currently not possible https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md

Is your feature related to a problem, if so please describe it.

An indexer like the ones for the electrum protocol should work without having access to the RPC interface, I think the only missing method from the REST interface is the tx broadcast.

Describe the solution you'd like

I would like another REST end point like the following:

POST /tx

Broadcast a raw transaction to the network.

The transaction should be provided as hex in the request body. The txid will be returned on success.

(hex is used for similarity with esplora API, binary would be ok)

Describe any alternatives you've considered

Using RPC requires an authenticated connection. Using the p2p network requires to know an additional endpoint and the peering from the indexer

Please leave any additional context

The REST interface already has risks https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md#risks and I don't think would be more risky to have tx broadcast

Transaction packages may be added in another endpoint

stickies-v commented 6 days ago

Using RPC requires an authenticated connection.

Could you please elaborate on why RPC or authentication is not a feasible option for your use case?

maflcko commented 6 days ago

Using RPC requires an authenticated connection.

Could you please elaborate on why RPC or authentication is not a feasible option for your use case?

I am not familiar with electrum protocol, but the issue description says:

An indexer like the ones for the electrum protocol should work without having access to the RPC interface

stickies-v commented 6 days ago

The "should work without having access to the RPC interface" is the part that I'd like to understand better. For example, the electrs docs specifically mention the bitcoind jsonrpc authentication: https://github.com/romanz/electrs/blob/master/doc/config.md#electrs-configuration

brunoerg commented 6 days ago

The "should work without having access to the RPC interface" is the part that I'd like to understand better. For example, the electrs docs specifically mention the bitcoind jsonrpc authentication: https://github.com/romanz/electrs/blob/master/doc/config.md#electrs-configuration

It's not clear to me as well. Maybe they need it to start using the REST interface?

RCasatta commented 6 days ago

Please see https://github.com/bitcoin/bitcoin/pull/31065#issuecomment-2417141803 for details