-
Notifications
You must be signed in to change notification settings - Fork 10
Add the option to manually sign transactions #43
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
Conversation
…tus-interface into gergely/manual-sign
| (map (encodeByteString . fromBuiltin . getPubKeyHash . Ledger.pubKeyHash) pubKeys) | ||
| ] | ||
| printLog @w Warn (Text.unpack err) | ||
| pure $ Left err |
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.
For manual signing, should the transaction error?
As far as a contract resulting in a manual sign goes, it did its job correctly
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.
Also, giving the tx here makes it pretty difficult to test contracts using this, i wonder if theres another way - perhaps a function specifically for under-signed transactions?
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 a bit unfinished, I just wanted to push it asap, but certainly I want to find a better way to handle this. Demanding manual intervention is pretty annoying, also if a contract contains multiple txs, the whole workflow could break.
I am also thinking about a way to inject a callback function to handle the unsigned tx. I'll try to sketch up something in the following days...
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.
That could certainly work! Please do keep me in the loop on this :)
src/BotPlutusInterface/Files.hs
Outdated
| let vKeyFiles = | ||
| map (\filename -> Text.unpack pabConf.pcSigningKeyFileDir ++ "/" ++ filename) $ | ||
| filter ("vkey" `isExtensionOf`) files | ||
| let sKeyFiles = | ||
| map (\filename -> Text.unpack pabConf.pcSigningKeyFileDir ++ "/" ++ filename) $ | ||
| filter ("skey" `isExtensionOf`) files |
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 feel like these could be combined in some way, are the files always either skey or vkey? if so, a partition could be used. either way, the map function could be applied before the filter to avoid writing it twice
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.
Fixed.
src/BotPlutusInterface/PreBalance.hs
Outdated
| case Map.lookup pkh privKeys of | ||
| Just privKey -> Right $ Tx.addSignature' privKey tx' | ||
| Just (FromSKey privKey) -> Right $ Tx.addSignature' privKey tx' | ||
| Just (FromVKey privKey) -> Right $ Tx.addSignature' privKey tx' |
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.
Can't you use unDummyPrivateKey here over unpacking directly?
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.
Fixed.
test/Spec/MockContract.hs
Outdated
| skeyToPubKey = | ||
| Ledger.toPublicKey | ||
| . Files.unDummyPrivateKey | ||
| . fromRight (error "Impossible happened") |
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.
How impossible are we talking, maybe give something a little more meaningful, since getting "impossible happened" in an error would not be super helpful
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.
Yeah, sorry about that. Fixed it.
src/BotPlutusInterface/Files.hs
Outdated
| _ | ||
| | "vkey" `isExtensionOf` filename -> Just <$> readVerificationKey @w fullPath | ||
| | "skey" `isExtensionOf` filename -> Just <$> readSigningKey @w fullPath | ||
| | otherwise -> pure Nothing |
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.
Theres a function to extract the extension of a file, maybe case over that instead of a guards only case?
|
@samuelWilliams99 Are you okay with merging this as it is? I don't know when will i have the time to find a better way for handling unsigned txs, it might just be the tx export function, you're currently working on. |
f0e9139 to
8fe4ed0
Compare
…tus-interface into gergely/manual-sign
Based on: #42
This PR introduces a way to delay the signing of transactions. This could be useful when we don't want to store the signing key(s) on the bot server. We still need their verification keys, in the same folder and in the same format as the signing keys, only with a
vkeyfile extension.