Skip to content

Commit f53da09

Browse files
chore(utxo-staking): set coredao devnet for testnet3
BTC-000 TICKET: BTC-000
1 parent 13c9dd6 commit f53da09

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

modules/utxo-staking/src/coreDao/opReturn.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { payments, networks } from '@bitgo/utxo-lib';
22

33
// Source: https://docs.coredao.org/docs/Learn/products/btc-staking/design
4+
export const CORE_DAO_DEVNET_CHAIN_ID = Buffer.from('0458', 'hex');
45
export const CORE_DAO_TESTNET_CHAIN_ID = Buffer.from('045b', 'hex');
56
export const CORE_DAO_MAINNET_CHAIN_ID = Buffer.from('045c', 'hex');
67
export const CORE_DAO_SATOSHI_PLUS_IDENTIFIER = Buffer.from('5341542b', 'hex');
@@ -77,7 +78,13 @@ export function createCoreDaoOpReturnOutputScript({
7778
}
7879
const versionBuffer = Buffer.alloc(1, version);
7980

80-
if (!(chainId.equals(CORE_DAO_TESTNET_CHAIN_ID) || chainId.equals(CORE_DAO_MAINNET_CHAIN_ID))) {
81+
if (
82+
!(
83+
chainId.equals(CORE_DAO_TESTNET_CHAIN_ID) ||
84+
chainId.equals(CORE_DAO_MAINNET_CHAIN_ID) ||
85+
chainId.equals(CORE_DAO_DEVNET_CHAIN_ID)
86+
)
87+
) {
8188
throw new Error('Invalid chain ID');
8289
}
8390

@@ -122,7 +129,7 @@ export function createCoreDaoOpReturnOutputScript({
122129

123130
const payment = payments.embed({
124131
data: [data],
125-
network: chainId.equals(CORE_DAO_TESTNET_CHAIN_ID) ? networks.testnet : networks.bitcoin,
132+
network: chainId.equals(CORE_DAO_DEVNET_CHAIN_ID) ? networks.testnet : networks.bitcoin,
126133
});
127134
if (!payment.output) {
128135
throw new Error('Unable to create OP_RETURN output');
@@ -166,9 +173,17 @@ export function parseCoreDaoOpReturnOutputScript(script: Buffer): OpReturnParams
166173

167174
// Decode chainId
168175
const chainId = Buffer.from(dataBuffer.subarray(offset, offset + 2));
169-
if (!(chainId.equals(CORE_DAO_TESTNET_CHAIN_ID) || chainId.equals(CORE_DAO_MAINNET_CHAIN_ID))) {
176+
if (
177+
!(
178+
chainId.equals(CORE_DAO_DEVNET_CHAIN_ID) ||
179+
chainId.equals(CORE_DAO_TESTNET_CHAIN_ID) ||
180+
chainId.equals(CORE_DAO_MAINNET_CHAIN_ID)
181+
)
182+
) {
170183
throw new Error(
171-
`Invalid ChainID: ${chainId.toString('hex')}. Must be either 0x045b (testnet) or 0x045c (mainnet).`
184+
`Invalid ChainID: ${chainId.toString(
185+
'hex'
186+
)}. Must be either 0x0458 (devnet), 0x045b (testnet), or 0x045c (mainnet).`
172187
);
173188
}
174189
offset += 2;

0 commit comments

Comments
 (0)