エラー:[LedgerFailure (DelegsFailure (WithdrawalsNotInRewardsDELEGS (fromList [(RewardAcnt {getRwdNetwork = Mainnet, getRwdCred = KeyHashObj (KeyHash “Hash value”)},Coin "coin amout")])))
#!/bin/bash
dstAddress=$(cat payment.addr)
echo '---------------------'
echo dstAddress: ${dstAddress}
rewards=$(cardano-cli query stake-address-info \
--mainnet \
--address $(cat stake.addr) | jq '.[0].rewardAccountBalance')
echo stakeRewards: ${rewards}
echo '---------------------'
currentSlot=$(cardano-cli query tip --mainnet | jq -r '.slot')
echo Current Slot: $currentSlot
cardano-cli query utxo \
--address $(cat payment.addr) \
--mainnet > fullUtxo.out
tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out
cat balance.out
tx_in=""
total_balance=0
while read -r utxo; do
in_addr=$(echo ${utxo} | awk '{ print $1 }')
idx=$(echo ${utxo} | awk '{ print $2 }')
utxo_balance=$(echo ${utxo} | awk '{ print $3 }')
total_balance=$((${total_balance}+${utxo_balance}))
echo TxHash: ${in_addr}#${idx}
echo ADA: ${utxo_balance}
tx_in="${tx_in} --tx-in ${in_addr}#${idx}"
done < balance.out
txcnt=$(cat balance.out | wc -l)
echo Total ADA balance: ${total_balance}
echo Number of UTXOs: ${txcnt}
cardano-cli transaction build-raw \
${tx_in} \
--tx-out $(cat payment.addr)+0 \
--withdrawal $(cat stake.addr)+0 \
--invalid-hereafter 0 \
--fee 0 \
--out-file withdraw_rewards.draft
fee=$(cardano-cli transaction calculate-min-fee \
--tx-body-file withdraw_rewards.draft \
--tx-in-count 1 \
--tx-out-count 1 \
--witness-count 2 \
--byron-witness-count 0 \
--mainnet \
--protocol-params-file protocol.json | awk '{print $1}')
echo fee: $fee
cardano-cli transaction build-raw \
${tx_in} \
--tx-out $(cat payment.addr)+$(( ${total_balance} - ${fee} + ${rewards} )) \
--withdrawal $(cat stake.addr)+${rewards} \
--invalid-hereafter $(( ${currentSlot} +10000)) \
--fee ${fee} \
--out-file withdraw_rewards.raw
cardano-cli transaction sign \
--tx-body-file withdraw_rewards.raw \
--signing-key-file payment.skey \
--signing-key-file stake.skey \
--mainnet \
--out-file withdraw_rewards.signed
cardano-cli transaction submit \
--tx-file withdraw_rewards.signed \
--mainnet
cardano-cli query utxo \
--address $(cat payment.addr) \
--mainnet
cardano-cli query stake-address-info \
--mainnet \
--address $(cat stake.addr)