smite: add transaction block position lookup to BitcoinCli#140
smite: add transaction block position lookup to BitcoinCli#140devvaansh wants to merge 2 commits into
Conversation
Add BitcoinCli::get_transaction_block_position, which returns the (block_height, tx_index) pair for a confirmed transaction. This is the information a fuzzer needs to derive the BOLT 7 short_channel_id of a mined 2-of-2 P2WSH funding output, and is a prerequisite for driving gossip messages past on-chain UTXO validation in CLN and LND. Signed-off-by: Devansh Vashisht <devansh.vashisht.ug24@nsut.ac.in>
There was a problem hiding this comment.
ACK
I assume that, with this, we’re only left with operation like ComputeShortChannelId, which resolve a funding tx, retrieve its block height and tx index, and compute the SCID from them? In that case, we also need to handle the case where the funding tx hasn't been confirmed yet
Yes, next PR adds |
I don’t think we should make the generator mine a specific number of blocks. I think we should keep it as a range, like If the tx is not confirmed, that's still a valid program, so it shouldn't panic. smite should only panic when the program (generated by smite) is invalid, in which case it’s a bug that should be fixed in |
morehouse
left a comment
There was a problem hiding this comment.
Please squash to a single commit.
| #[derive(Deserialize)] | ||
| struct GetRawTransactionResponse { | ||
| // Omitted by `getrawtransaction` while the transaction is unconfirmed | ||
| // (in the mempool). | ||
| blockhash: Option<String>, | ||
| } |
There was a problem hiding this comment.
We now have two functions that call getrawtransaction. It would seem natural to have a private helper that returns the GetRawTransactionResponse.
| let block_out = self | ||
| .run() | ||
| .arg("getblock") | ||
| .arg(&blockhash) | ||
| .output() | ||
| .expect("bitcoin-cli getblock should not fail"); |
There was a problem hiding this comment.
It might be good to explicitly set verbosity=1 so that this doesn't break if the default verbosity ever changes.
Adds
BitcoinCli::get_transaction_block_position, which returns the(block_height, tx_index)pair for a confirmed transaction by issuinggetrawtransactionfollowed bygetblock. ReturnsNonefor unconfirmed or unknown transactions.This is the missing piece needed to derive a BOLT 7
short_channel_idfrom a mined 2-of-2 P2WSH funding output, and is a prerequisite for theLookupShortChannelIdIR operation that will letChannelAnnouncementGeneratorpass on-chain UTXO validation in CLN and LND.Ref: #71