How to add support for new L1 blockchains to Coinshift.
| Chain | Ticker | Default RPC Port | Confirmations |
|---|---|---|---|
| Bitcoin | BTC | 8332 | 6 |
| Bitcoin Cash | BCH | 8332 | 3 |
| Litecoin | LTC | 9332 | 3 |
| Bitcoin Signet | sBTC | 38332 | 3 |
| Bitcoin Regtest | rBTC | 18443 | 3 |
A blockchain must implement these Bitcoin Core JSON-RPC methods:
getblockchaininfo — current block height and chain infogetrawtransaction — fetch transaction details by txidlistunspent — list UTXOs for an addressgetreceivedbyaddress — alternative transaction discoveryResponses must follow Bitcoin Core's JSON-RPC format. The getrawtransaction response (verbose) must include: txid, confirmations, blockheight (optional), vout with value and scriptPubKey.address, and vin with txid and vout.
Edit lib/types/swap.rs:
pub enum ParentChainType {
BTC,
BCH,
LTC,
Signet,
Regtest,
NewChain, // Add your new chain
}
Update all impl ParentChainType methods with your chain's values:
impl ParentChainType {
pub fn default_confirmations(&self) -> u32 {
match self {
// ...
Self::NewChain => 6,
}
}
pub fn default_rpc_port(&self) -> u16 {
match self {
// ...
Self::NewChain => 8555,
}
}
pub fn coin_name(&self) -> &'static str {
match self {
// ...
Self::NewChain => "New Chain",
}
}
pub fn ticker(&self) -> &'static str {
match self {
// ...
Self::NewChain => "NEW",
}
}
// Also update: to_bitcoin_network(), sats_per_coin(),
// default_rpc_url_hint(), all()
}
Edit app/gui/l1_config.rs to add setup hints:
match self.selected_parent_chain {
// ...
ParentChainType::NewChain => {
ui.label("Use NewChain Core with -txindex=1.");
}
}
# getblockchaininfo
curl -u user:password --data-binary \
'{"jsonrpc":"2.0","id":1,"method":"getblockchaininfo","params":[]}' \
-H 'content-type: application/json' http://localhost:PORT/
# getrawtransaction (replace TXID)
curl -u user:password --data-binary \
'{"jsonrpc":"2.0","id":1,"method":"getrawtransaction","params":["TXID",true]}' \
-H 'content-type: application/json' http://localhost:PORT/
# listunspent (replace ADDRESS)
curl -u user:password --data-binary \
'{"jsonrpc":"2.0","id":1,"method":"listunspent","params":[0,999999,["ADDRESS"]]}' \
-H 'content-type: application/json' http://localhost:PORT/
If your chain has RPC differences, extend ParentChainRpcClient:
impl ParentChainRpcClient {
pub fn get_transaction_for_chain(
&self, txid: &str, chain: ParentChainType,
) -> Result<TransactionInfo, Error> {
match chain {
ParentChainType::NewChain => { /* custom handling */ }
_ => self.get_transaction(txid),
}
}
}
Each parent chain node needs:
-txindex=1rpcuser, rpcpassword, rpcportExample config file:
server=1
txindex=1
rpcuser=myuser
rpcpassword=mypassword
rpcport=8332
rpcallowip=127.0.0.1
Configure the connection in Coinshift via the GUI (L1 Config tab) or edit the config file directly:
~/.local/share/coinshift/l1_rpc_configs.json~/Library/Application Support/coinshift/l1_rpc_configs.json%APPDATA%\coinshift\l1_rpc_configs.json#[test]
fn test_new_chain_config() {
let chain = ParentChainType::NewChain;
assert_eq!(chain.default_rpc_port(), 8555);
assert_eq!(chain.coin_name(), "New Chain");
assert_eq!(chain.ticker(), "NEW");
}
txindex=1 is set; restart with -reindex if neededEnable debug logging:
RUST_LOG=coinshift::parent_chain_rpc=debug ./coinshift-gui
When submitting a PR for a new parent chain, include:
lib/types/swap.rs (enum + helper methods)app/gui/l1_config.rs (UI hints)