rooch-network / rooch

VApp Container with Move Language for Bitcoin ecosystem
https://rooch.network
Apache License 2.0
163 stars 86 forks source link

[bitcoin] Auto generate new block when broadcast Bitcoin tx in local network #2651

Open jolestar opened 2 months ago

jolestar commented 2 months ago

Proposal Details

On the Bitcoin regtest network, developers need to manually trigger a new block via the bitcoin-cli generatetoaddress command.

Some examples are in the document Bitcoin local development environment and test cases in bitseed and bitcoin.

We can auto-generate a new block when broadcasting Bitcoin tx via RPC

https://github.com/rooch-network/rooch/blob/2d65e2e06cadca20616da0a040829a95a1b93355/crates/rooch-rpc-api/src/api/btc_api.rs#L39-L46

Note: this only available for Roch local network and Bitcoin regtest network.

wfnuser commented 1 month ago

Maybe I can have a try on this one?

wfnuser commented 4 weeks ago

@jolestar Hi, I’ve just started looking into this issue and wanted to clarify. When you mentioned “auto-generate new block,” did you mean that after the client requests to broadcast a transaction, it should then send an additional request to generate a new block?

If that’s the case, could you provide some guidance on where the logic for packaging transactions into a block is implemented? That would help me get started, thanks!

jolestar commented 3 weeks ago

The bitcoin cli generates a new block via a command; it should be an RPC request.

bitcoin-cli generatetoaddress 1 <address>

https://github.com/rooch-network/rooch/tree/main/scripts/bitcoin

jolestar commented 3 weeks ago

Make this TBD after discussing it with @wfnuser.