Functions to create and manage Orchard commitment trees #99

Merged
pitmutt merged 30 commits from rav001 into milestone2 2024-11-05 18:28:46 +00:00
Showing only changes of commit 24210b1e0b - Show all commits

View file

@ -132,40 +132,20 @@ createTransaction ::
-> ZcashNet -- ^ the network to be used -> ZcashNet -- ^ the network to be used
-> Int -- ^ target block height -> Int -- ^ target block height
-> Bool -- ^ True to build, False to estimate fee -> Bool -- ^ True to build, False to estimate fee
-> Either TxError HexString -> HexString
createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing znet bh build = createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing znet bh build =
processResult $! txResult withPureBorshVarBuffer $
where rustWrapperCreateTx
processResult :: HexString -> Either TxError HexString (case sapAnchor of
processResult input Nothing -> "0"
| BS.length (hexBytes input) > 1 = Right input Just sA -> toBytes $ sapTree sA)
| otherwise = (case orchAnchor of
case head (BS.unpack $ hexBytes input) of Nothing -> "0"
0 -> Left InsufficientFunds Just oA -> toBytes $ orchTree oA)
1 -> Left ChangeRequired tSpend
2 -> Left Fee sSpend
3 -> Left Balance oSpend
4 -> Left TransparentBuild outgoing
5 -> Left SaplingBuild (znet == MainNet)
6 -> Left OrchardBuild (fromIntegral bh)
7 -> Left OrchardSpend build
8 -> Left OrchardRecipient
9 -> Left SaplingBuilderNotAvailable
10 -> Left OrchardBuilderNotAvailable
_ -> Left ZHError
txResult =
withPureBorshVarBuffer $
rustWrapperCreateTx
(case sapAnchor of
Nothing -> "0"
Just sA -> toBytes $ sapTree sA)
(case orchAnchor of
Nothing -> "0"
Just oA -> toBytes $ orchTree oA)
tSpend
sSpend
oSpend
outgoing
(znet == MainNet)
(fromIntegral bh)
build