@@ -28,11 +28,6 @@ echo "🔐 Generating random password for badger encryption..."
2828BADGER_PASSWORD=$( < /dev/urandom tr -dc ' A-Za-z0-9' | head -c 32)
2929echo " ✅ Generated password: $BADGER_PASSWORD "
3030
31- # Generate chain_code (32-byte hex value, 64 hex characters)
32- echo " 🔐 Generating chain_code (32-byte hex)..."
33- CHAIN_CODE=$( openssl rand -hex 32)
34- echo " ✅ Generated chain_code: $CHAIN_CODE "
35-
3631# Generate config.test.yaml from template
3732echo " 📝 Generating config.test.yaml from template..."
3833if [ ! -f " config.test.yaml.template" ]; then
@@ -48,7 +43,6 @@ ESCAPED_PASSWORD=$(printf '%s\n' "$BADGER_PASSWORD" | sed 's/[[\.*^$()+?{|]/\\&/
4843
4944sed -e " s/{{\.BadgerPassword}}/$ESCAPED_PASSWORD /g" \
5045 -e " s/{{\.EventInitiatorPubkey}}/$TEMP_PUBKEY /g" \
51- -e " s/{{\.CKDChainCode}}/$CHAIN_CODE /g" \
5246 config.test.yaml.template > config.test.yaml
5347
5448echo " ✅ Generated config.test.yaml from template"
@@ -112,35 +106,20 @@ if [ -f "test_event_initiator.identity.json" ]; then
112106 PUBKEY=$( cat test_event_initiator.identity.json | jq -r ' .public_key' )
113107 echo " 📝 Updating config files with event initiator public key and password..."
114108
115- # Update all test node config files with the actual public key, password, and chain_code
109+ # Update all test node config files with the actual public key and password
116110 for i in $( seq 0 $(( NUM_NODES- 1 )) ) ; do
117111 # Update public key using sed with | as delimiter (safer than /)
118112 sed_inplace " s|event_initiator_pubkey:.*|event_initiator_pubkey: $PUBKEY |g" " $BASE_DIR /test_node$i /config.yaml"
119113 # Update password using sed with | as delimiter and escaped password
120114 sed_inplace " s|badger_password:.*|badger_password: $ESCAPED_PASSWORD |g" " $BASE_DIR /test_node$i /config.yaml"
121- # Update chain_code
122- if grep -q ' ^\s*chain_code:' " $BASE_DIR /test_node$i /config.yaml" ; then
123- sed_inplace " s|chain_code:.*|chain_code: \" $CHAIN_CODE \" |g" " $BASE_DIR /test_node$i /config.yaml"
124- else
125- printf ' \nchain_code: "%s"\n' " $CHAIN_CODE " >> " $BASE_DIR /test_node$i /config.yaml"
126- fi
127115 done
128116
129117 # Also update the main config.test.yaml
130118 sed_inplace " s|event_initiator_pubkey:.*|event_initiator_pubkey: $PUBKEY |g" " $BASE_DIR /config.test.yaml"
131119 sed_inplace " s|badger_password:.*|badger_password: $ESCAPED_PASSWORD |g" " $BASE_DIR /config.test.yaml"
132- # Update chain_code in config.test.yaml if it was replaced with placeholder
133- if grep -q ' {{\.CKDChainCode}}' " $BASE_DIR /config.test.yaml" 2> /dev/null; then
134- sed_inplace " s|{{\.CKDChainCode}}|$CHAIN_CODE |g" " $BASE_DIR /config.test.yaml"
135- elif grep -q ' ^\s*chain_code:' " $BASE_DIR /config.test.yaml" ; then
136- sed_inplace " s|chain_code:.*|chain_code: \" $CHAIN_CODE \" |g" " $BASE_DIR /config.test.yaml"
137- else
138- printf ' \nchain_code: "%s"\n' " $CHAIN_CODE " >> " $BASE_DIR /config.test.yaml"
139- fi
140120
141121 echo " ✅ Event initiator public key updated: $PUBKEY "
142122 echo " ✅ Badger password updated: $BADGER_PASSWORD "
143- echo " ✅ Chain code updated: $CHAIN_CODE "
144123else
145124 echo " ❌ Failed to generate event initiator identity"
146125 exit 1
0 commit comments