-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display serialised tx endpoint #2977
Display serialised tx endpoint #2977
Conversation
2a0666c
to
db7a720
Compare
lib/core/src/Cardano/Wallet.hs
Outdated
[] -> (txin, Nothing) -- will probably use error here | ||
path':_ -> (txin, Just (txout, path')) | ||
|
||
extAddr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We could probably find a more descriptive name than
extAddr
. Seems similar to the existingnormalizeDelegationAddress
, but perhaps different enough not to combine. - But... Why are we modifying the address in the first place? 🤔 That seems very off to me. We should be looking up addresses based on their payment key hashes only, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ad 1. yes, normaliseDelegationAddress
does almost the same as extAddr
ad 2. Why we needed? Because in the cbor there is delegation address as represented in the chain. and we store fingerprints really, so we need to adjust them in order to compare.
lib/core/src/Cardano/Wallet.hs
Outdated
where | ||
db = ctx ^. dbLayer @IO @s @k | ||
tryGetTxOutPath cp walletAddrs txin = | ||
case UTxO.lookup txin (totalUTxO mempty cp) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't totalUTxO mempty cp
the same thing as utxo cp
? But seems good that we don't remove the inputs from the pending txs — I take the pending txs wouldn't be decodable/displayable then.
Also, not sure we need to nor if we should, but we could:
- Use
changeUTxO pending s <> utxo
(but not excluding pending inputs), to be able to resolve chains of dependent txs (I don't think this would work currently) - Use LSQ to (potentially)
lookup
thetxin
in the node's fullUTxO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about pending txs. I would for now use totalUTxO mempty cp
and think about pending tx in the next move
128ca64
to
e8ee5bf
Compare
@paweljakubas Sorry, but I didn't see the point of most of the complicated (and seemingly a bit out-of-place) logic in lookupTx{Ins,Outs} 😅 I tried replacing most of it with just Could you let me know if it looks good to you or whether I have misunderstood something? |
maybe it is ok to reuse |
lib/core/src/Cardano/Wallet.hs
Outdated
, ix ) | ||
let walletAddrs = map f $ knownAddresses (getState cp) | ||
|
||
--We are analyzing the next gapPool change addresses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we need this changeAddrs, otherwise source wallet will not see change address in outputs UNTIL the wallet discovers tx (so after submit). That is consequence of decoupling construction/signing/submitting and persisting pending things only during submitting
@@ -479,7 +479,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do | |||
let addrDest = (addrs !! addrIx) ^. #id | |||
let expectedTxOutTarget = WalletOutput $ ApiWalletOutput | |||
{ address = addrDest | |||
, amount = Quantity 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it should be 0. This is what is currently in this address. So after construction, source wallet does not see this as WalletOutput but ExternalOutput. Target wallet see this as WalletOuptut, and see amountIncoming=Quantity amt
, but amount=Quantity 0
as there is nothing at THIS stage in this wallet. Right? It is going to be amount=amountIncoming
after discovery. I did this on purpose to have a way to see whole cycle if this resource is ours :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see line 548 and
let expectedTxOutTarget' = WalletOutput $ ApiWalletOutput
{ address = addrDest
, amount = Quantity amt -- now we have this
, assets = ApiT TokenMap.empty
, derivationPath = NE.fromList
[ ApiT (DerivationIndex 2147485500)
, ApiT (DerivationIndex 2147485463)
, ApiT (DerivationIndex 2147483648)
, ApiT (DerivationIndex 0)
, ApiT (DerivationIndex $ fromIntegral addrIx)
]
, amountIncoming = Quantity amt
, assetsIncoming = ApiT TokenMap.empty
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is after submitting and discovering
post rebase adjustments
some cleaning
32480e1
to
1746cac
Compare
This commit does sacrifice the distinction between amount and amount_incoming. The next commit addresses that.
My reason being the combination of: 1. Unclear why we need it for this task / now. There might be interesting things to do here, but that we should be clear about what problem we're trying to solve, such that we can create a solution we're fully confident in. 2. Exposing balances of individual addresses feels at odds with the point of the wallet otherwise being maintaining a concept of balance for all addresses combined. 3. It seemed to make the implementation much more complicated
1. Check that the change output is recognized 2. Use `shouldContain` and `shouldNotContain` rather than `shouldSatisfy` and `elem` for nicer error messages.
2dd3ccd
to
f7977b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! Hoping we at some point later on can get CBOR <-> JSON roundtrip properties, which I believe would be the ultimate test that we display all information!
bors r+ |
, expectField #outputs (`shouldNotContain` [expectedTxOutTarget]) | ||
|
||
-- Check that the change output is there: | ||
, expectField (#outputs) ((`shouldBe` 1) . length . filter isOutOurs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check for the change output in the last commit along with a slight tweak, using should{Not}Contain [txOut]
rather than shouldSatisfy
and elem
, which should produce nicer error messages and be slightly simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good change
@Anviking thanks for the thorough review and commits! I will create following ticket in which we property test using genTx and expose mint/burn and other things in this endpoint |
Build succeeded: |
adp-974
decodeTransaction
in ServerlookupTxIns
in WalletlookupTxOuts
in WalletThe endpoint acts in the context of a given wallet and is able to detect the wallet's resources. In detail, the enpdoint detects:
Comments
Issue Number