packages feed

haskoin-core 0.9.0 → 0.9.1

raw patch · 3 files changed

+19/−6 lines, 3 files

Files

CHANGELOG.md view
@@ -4,6 +4,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.9.1+### Added+- Add a function to produce a structured signature over a transaction.+- Enable `-O2` optimisations.+ ## 0.9.0 ### Changed - Address conversion to string now defined for all inputs.
haskoin-core.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 88ebd4a51caa718564de69955c74a49d2279bc2d1fe883c83ae035f529168813+-- hash: 571964654e85fdc471bd843a2c43a1debee35c14aca24a8cdba815efd5c09736  name:           haskoin-core-version:        0.9.0+version:        0.9.1 synopsis:       Bitcoin & Bitcoin Cash library for Haskell description:    Haskoin Core is a complete Bitcoin and Bitcoin Cash library of functions and data types for Haskell developers. category:       Bitcoin, Finance, Network@@ -80,6 +80,7 @@       Paths_haskoin_core   hs-source-dirs:       src+  ghc-options: -O2   build-depends:       QuickCheck     , aeson
src/Network/Haskoin/Transaction/Builder.hs view
@@ -20,6 +20,7 @@     , buildInput     , SigInput(..)     , signTx+    , makeSignature     , signInput     , verifyStdTx     , mergeTxs@@ -275,7 +276,7 @@     , sigInputValue  :: !Word64       -- ^ output script value     , sigInputOP     :: !OutPoint     -- ^ outpoint to spend     , sigInputSH     :: !SigHash      -- ^ signature type-    , sigInputRedeem :: !(Maybe RedeemScript) -- ^ sedeem script+    , sigInputRedeem :: !(Maybe RedeemScript) -- ^ redeem script     } deriving (Eq, Show, Read, Generic, Hashable)  instance ToJSON SigInput where@@ -313,16 +314,22 @@         keys <- sigKeys so rdmM allKeys         foldM (\t k -> signInput net t i sigi k) tx keys +-- | Produce a structured representation of a deterministic (RFC-6979) signature over an input.+makeSignature :: Network -> Tx -> Int -> SigInput -> SecKeyI -> TxSignature+makeSignature net tx i (SigInput so val _ sh rdmM) key =+    TxSignature (signHash (secKeyData key) m) sh+  where+    m = txSigHash net tx (encodeOutput $ fromMaybe so rdmM) val i sh+ -- | Sign a single input in a transaction deterministically (RFC-6979). signInput :: Network -> Tx -> Int -> SigInput -> SecKeyI -> Either String Tx-signInput net tx i (SigInput so val _ sh rdmM) key = do-    let sig = TxSignature (signHash (secKeyData key) m) sh+signInput net tx i sigIn@(SigInput so val _ sh rdmM) key = do+    let sig = makeSignature net tx i sigIn key     si <- buildInput net tx i so val rdmM sig $ derivePubKeyI key     let ins = updateIndex i (txIn tx) (f si)     return $ Tx (txVersion tx) ins (txOut tx) [] (txLockTime tx)   where     f si x = x {scriptInput = encodeInputBS si}-    m = txSigHash net tx (encodeOutput $ fromMaybe so rdmM) val i sh  -- | Order the 'SigInput' with respect to the transaction inputs. This allows -- the user to provide the 'SigInput' in any order. Users can also provide only