English
How to fix the Mnemonic staking balance bug

🛑
Am I affected?

Check if you created your stake / payment key pair on step 7 with the mnemonic method from Daedalus 2.0 before July 30, 2020.
Run the following to see if you're affected
1
cd $NODE_HOME
2
wc -m payment.addr
Copied!
If this returns 59 payment.addr, then continue reading. If this returns 104 payment.addr, you are not affected!

🛠
What is the problem?

  • The balance towards your stake is not being counted because the script's default, payment.addr, is also known as the enterprise address.
  • By design, enterprise address balances are not counted as stake.
  • The public address found in base.addr should have been funded. In other words, base.addr should have been the real payment.addr.

🤖
Verify that the problem exists

Check your stake balance by running the following query to find all your stake pool's delegators.
1
cd $NODE_HOME
2
pool_id=$(cat stakepoolid.txt)
3
timeout -k 5 60 cardano-cli shelley query ledger-state ${NETWORK_IDENTIFIER} --out-file ledger-state.json
4
echo "Ledger state dumped, parsing data..."
5
non_myopic_delegators=$(jq -r -c ".esNonMyopic.snapNM._delegations | .[] | select(.[1] == \"${pool_id}\") | .[0][\"key hash\"]" ledger-state.json)
6
snapshot_delegators=$(jq -r -c ".esSnapshots._pstakeSet._delegations | .[] | select(.[1] == \"${pool_id}\") | .[0][\"key hash\"]" ledger-state.json)
7
lstate=$(jq -r -c ".esLState" ledger-state.json)
8
lstate_dstate=$(jq -r -c "._delegationState._dstate" <<< "${lstate}")
9
ledger_pool_state=$(jq -r -c '._delegationState._pstate._pParams."'"${pool_id}"'" // empty' <<< "${lstate}")
10
lstate_rewards=$(jq -r -c "._rewards" <<< "${lstate_dstate}")
11
lstate_utxo=$(jq -r -c "._utxoState._utxo" <<< "${lstate}")
12
lstate_delegators=$(jq -r -c "._delegations | .[] | select(.[1] == \"${pool_id}\") | .[0][\"key hash\"]" <<< "${lstate_dstate}")
13
delegators=$(echo "${non_myopic_delegators}" "${snapshot_delegators}" "${lstate_delegators}" | tr ' ' '\n' | sort -u)
14
echo "$(wc -w <<< "${delegators}") delegators found, gathering data for each:"
15
pledge="$(jq -c -r '.pledge // 0' <<< "${ledger_pool_state}" | tr '\n' ' ')"
16
owners="$(jq -c -r '.owners[] // empty' <<< "${ledger_pool_state}" | tr '\n' ' ')"
17
owner_nbr=$(jq -r '(.owners | length) // 0' <<< "${ledger_pool_state}")
18
delegators_array=()
19
delegator_nbr=0
20
total_stake=0
21
total_pledged=0
22
for key in ${delegators}; do
23
stake=$(jq -r -c ".[] | select(.address | contains(\"${key}\")) | .amount" <<< "${lstate_utxo}" | awk 'BEGIN{total = 0} {total = total + $1} END{printf "%.0f", total}')
24
rewards=$(jq -r -c ".[] | select(.[0][\"key hash\"] == \"${key}\") | .[1]" <<< "${lstate_rewards}")
25
total_stake=$((total_stake + stake + reward))
26
echo "Delegator $((++delegator_nbr)) processed"
27
if echo "${owners}" | grep -q "${key}"; then
28
key="${key} (owner)"
29
total_pledged=$((total_pledged + stake + reward))
30
fi
31
delegators_array+=( "hex_key" "${key}" "stake" "${stake}" "rewards" "${rewards})" )
32
done
33
echo total_stake $total_stake
34
echo total_pledged $total_pledged
35
echo delegator_nbr $delegator_nbr
36
37
printf '{"%s":"%s","%s":"%s","%s":"%s"},\n' "${delegators_array[@]}" | sed '$s/,$//'
Copied!
If you see stake is 0 for the owner, then the issue exists.
Example output:
{"hex_key":"70f2... (owner)","stake":"0","rewards":"0)"},

🧩
What is the fix?

1) Find your base.addr public address.
1
cat $NODE_HOME/extractedPoolKeys/base.addr
Copied!
2) Open Daedalus wallet which is where your mnemonic was originally created from.
3) Send a small test amount to the base.addr public address.
4) Re-run the above query to check your delegator's balances. Your owner's stake balance should have increased.
5) Send the remaining balance to base.addr public address.
6) Re-run the above query to verify your stake is correctly counted.
7) Replace the old payment.addr with base.addr
1
cd $NODE_HOME
2
cp extractedPoolKeys/base.addr payment.addr
Copied!
If you need assistance, please visit our Telegram Channel.
Last modified 1yr ago