From b03f835f8f0b4eb81f7bc64f719fe8006b0fb6c6 Mon Sep 17 00:00:00 2001 From: Tim Makarios Date: Thu, 19 Jun 2014 13:01:54 +1200 Subject: [PATCH] Remove dependency on rsign by submitting secret to a trusted server --- rootstock.hs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/rootstock.hs b/rootstock.hs index 9475a61..6aec30e 100644 --- a/rootstock.hs +++ b/rootstock.hs @@ -239,10 +239,8 @@ instance FromJSON RecordedTransaction where -------------------------------------------------------------------------------- -secretFile, rsignPath, sqlPassFile :: FilePath +secretFile, sqlPassFile :: FilePath secretFile = "/home/tim/Documents/passwords/ripple-secret.gpg" -rsignPath = - "/home/tim/build/ripple/ripple-lib/node_modules/ripple-lib/bin/rsign.js" sqlPassFile = "/home/tim/Documents/passwords/sql-password.gpg" connString :: BS.ByteString @@ -336,15 +334,6 @@ makeTransactions vs trf nextSeq = OfferCreate (amount (-q0 / trf x0) x0) (amount q1 x1) curSeq Nothing -------------------------------------------------------------------------------- -signTransaction :: Transaction -> RootstockIO String -signTransaction tx = do - sec <- gets secret - blobNewLine <- lift $ readProcess - rsignPath [sec, BSL8.unpack $ encode tx] "" - return $ init blobNewLine - - --------------------------------------------------------------------------------- getSqlConnection :: RootstockIO Connection getSqlConnection = gets sql @@ -477,12 +466,13 @@ askUntilAnswered question = do waitForType :: RootstockIO Ledger askUntilAnswered question -signAndSend :: Transaction -> RootstockIO () -signAndSend tx = do - txBlob <- signTransaction tx +submitToTrustedServer :: Transaction -> RootstockIO () +submitToTrustedServer tx = do + sec <- gets secret sendTextData $ encode $ object [ "command" .= ("submit" :: Text) - , "tx_blob" .= txBlob + , "tx_json" .= tx + , "secret" .= sec ] subscribe :: [Pair] -> WS.ClientApp () @@ -557,7 +547,7 @@ checkRunning = ifRunning $ return () submitUntilSequenceCatchup' :: [Transaction] -> ExceptionalRootstock () submitUntilSequenceCatchup' txs = unless (null txs) $ do checkRunning - forM_ txs $ lift . signAndSend + forM_ txs $ lift . submitToTrustedServer lift (waitForType :: RootstockIO Ledger) curSeq <- currentSequence <$> lift getAccountInfo submitUntilSequenceCatchup' $ dropWhile ((curSeq >) . getSequence) txs -- 2.11.4.GIT