fix: correct fee calculation for shielding

This commit is contained in:
Rene Vergara 2024-10-27 06:27:59 -05:00
parent 28a75895f4
commit 0e5f476e28
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -827,7 +827,6 @@ shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
dRecvs
forM fNotes $ \trNotes -> do
let noteTotal = getTotalAmount (trNotes, [], [])
let fee = calculateTxFee (trNotes, [], []) 4
tSpends <-
liftIO $
prepTSpends
@ -839,27 +838,53 @@ shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
let oRcvr =
fromJust $
o_rec =<< isValidUnifiedAddress (E.encodeUtf8 internalUA)
let snote =
let dummy =
OutgoingNote
4
(getBytes $ getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc)
(getBytes oRcvr)
(fromIntegral $ noteTotal - fee)
(fromIntegral $ noteTotal - 5000)
""
True
let tx =
let feeResponse =
createTransaction
Nothing
Nothing
tSpends
[]
[]
[snote]
[dummy]
znet
(bh + 3)
True
logDebugN $ T.pack $ show tx
return tx
bh
False
case feeResponse of
Left e1 -> return $ Left Fee
Right fee -> do
let feeAmt =
fromIntegral
(runGet getInt64le $ LBS.fromStrict $ toBytes fee)
let snote =
OutgoingNote
4
(getBytes $
getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc)
(getBytes oRcvr)
(fromIntegral $ noteTotal - feeAmt)
""
True
let tx =
createTransaction
Nothing
Nothing
tSpends
[]
[]
[snote]
znet
(bh + 3)
True
logDebugN $ T.pack $ show tx
return tx
where
getTotalAmount ::
( [Entity WalletTrNote]