Create script to register btc coinbase transaction#65
Open
julia-zack wants to merge 1 commit into
Open
Conversation
Dependency ReviewThe following issues were found:
OpenSSF ScorecardScorecard details
Scanned Files
|
c12adb1 to
5356bbc
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a Node.js tool script intended to sign (and optionally broadcast) an RSK Bridge registerBtcCoinbaseTransaction call, reusing the existing coinbase “information ready” builder, and introduces ethers as a dependency to perform transaction signing.
Changes:
- Added
tool/registerBtcCoinbaseTransaction.jsto build calldata, sign a legacy tx, and optionally broadcast viaeth_sendRawTransaction. - Exported
getInformationReadyForRegisterBtcCoinbaseTransactionfor reuse by other scripts. - Added
ethers@6.16.0topackage.json(and updatedpackage-lock.jsonaccordingly).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tool/registerBtcCoinbaseTransaction.js | New script to sign/broadcast a Bridge registerBtcCoinbaseTransaction call (currently has runtime-breaking issues noted in comments). |
| tool/getInformationReadyForRegisterBtcCoinbaseTransaction.js | Exports helper function; needs a CLI entrypoint guard to avoid require-time side effects. |
| package.json | Adds ethers dependency. |
| package-lock.json | Lockfile updates for ethers and transitive deps. |
Comments suppressed due to low confidence (1)
tool/getInformationReadyForRegisterBtcCoinbaseTransaction.js:119
- This file now exports
getInformationReadyForRegisterBtcCoinbaseTransaction, but it still executes its CLI IIFE at require-time. Any script thatrequire()s this module will unexpectedly run the CLI flow (and mayprocess.exit(1)viaparseBridgeRegisterBtcCliArgs). Guard the CLI entrypoint withif (require.main === module).
})();
module.exports = { getInformationReadyForRegisterBtcCoinbaseTransaction };
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const path = require('path'); | ||
| require('dotenv').config({ path: path.join(__dirname, '..', '.env'), quiet: true }); | ||
|
|
||
| const { ethers } = require('ethers'); |
Comment on lines
+32
to
+41
| const network = await provider.getNetwork(); | ||
| const btcTxHash = process.argv[2];; | ||
| const { | ||
| btcTxSerialized, | ||
| blockHash, | ||
| pmtSerialized, | ||
| witnessMerkleRoot, | ||
| witnessReservedValue | ||
| } = await getInformationReadyForRegisterBtcCoinbaseTransaction(network, btcTxHash); | ||
|
|
Comment on lines
+57
to
+59
| const data = iface.encodeFunctionData('registerBtcCoinbaseTransaction', [ | ||
| btcTxSerialized, blockHash, pmtSerialized, witnessMerkleRoot, witnessReservedValue, | ||
| ]); |
Comment on lines
+61
to
+62
| const chainId = network.chainId; | ||
| const nonce = await provider.getTransactionCount(wallet.address, 'pending'); |
Comment on lines
+5
to
+13
| * Get the 5 values first: | ||
| * node tool/getInformationReadyForRegisterBtcCoinbaseTransaction.js testnet <btcTxidInBlock> \ | ||
| * and save the {btcTxSerialized, btcBlockHash, pmtSerialized, witnessMerkleRoot, witnessReservedValue} | ||
| * object into a JSON file, e.g. coinbase-values.json | ||
| * | ||
| * Usage: | ||
| * node tool/registerBtcCoinbaseTransaction.js --btcTxHash # dry run: prints the raw signed tx | ||
| * node tool/registerBtcCoinbaseTransaction.js --btcTxHash --send # also broadcasts via eth_sendRawTransaction | ||
| */ |
marcos-iov
reviewed
Jun 11, 2026
| "dependencies": { | ||
| "chai": "6.2.2", | ||
| "dotenv": "17.4.2", | ||
| "ethers": "6.16.0", |
Contributor
There was a problem hiding this comment.
If it's just for the tool it can be a devDependency
Comment on lines
+20
to
+21
| const BRIDGE_ADDRESS = '0x0000000000000000000000000000000001000006'; | ||
| const BRIDGE_ABI = [ |
Contributor
There was a problem hiding this comment.
Maybe use precompiled-abis for this? Can be a devDependency as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.