Safe Haskell | None |
---|
This package provides functions for building and signing both simple transactions and multisignature transactions.
- buildTx :: [OutPoint] -> [(ScriptOutput, Word64)] -> Either String Tx
- buildAddrTx :: [OutPoint] -> [(String, Word64)] -> Either String Tx
- data SigInput
- signTx :: Monad m => Tx -> [SigInput] -> [PrvKey] -> SecretT (BuildT m) Tx
- detSignTx :: Tx -> [SigInput] -> [PrvKey] -> Build Tx
- isTxComplete :: Tx -> Bool
- data Coin = Coin {}
- chooseCoins :: Word64 -> Word64 -> [Coin] -> Either String ([Coin], Word64)
- chooseMSCoins :: Word64 -> Word64 -> (Int, Int) -> [Coin] -> Either String ([Coin], Word64)
- guessTxSize :: Int -> [(Int, Int)] -> Int -> Int -> Int
Build Transactions
buildTx :: [OutPoint] -> [(ScriptOutput, Word64)] -> Either String TxSource
Build a transaction by providing a list of outpoints as inputs
and a list of ScriptOutput
and amounts as outputs.
buildAddrTx :: [OutPoint] -> [(String, Word64)] -> Either String TxSource
Build a transaction by providing a list of outpoints as inputs and a list of recipients addresses and amounts as outputs.
Transaction signing
Data type used to specify the signing parameters of a transaction input. To sign an input, the previous output script, outpoint and sighash are required. When signing a pay to script hash output, an additional redeem script is required.
SigInput | Parameters for signing a pay to public key hash output. |
SigInputSH | Parameters for signing a pay to script hash output. |
isTxComplete :: Tx -> BoolSource
Returns True if all the inputs of a transactions are non-empty and if all multisignature inputs are fully signed.
Coin selection
A Coin is something that can be spent by a transaction and is represented by a transaction output, an outpoint and optionally a redeem script.
Coin | |
|
:: Word64 | Target price to pay. |
-> Word64 | Fee price per 1000 bytes. |
-> [Coin] | List of coins to choose from. |
-> Either String ([Coin], Word64) | Coin selection result and change amount. |
Coin selection algorithm for normal (non-multisig) transactions. This function returns the selected coins together with the amount of change to send back to yourself, taking the fee into account.
:: Word64 | Target price to pay. |
-> Word64 | Fee price per 1000 bytes. |
-> (Int, Int) | Multisig parameters m of n (m,n). |
-> [Coin] | List of coins to choose from. |
-> Either String ([Coin], Word64) | Coin selection result and change amount. |
Coin selection algorithm for multisignature transactions. This function returns the selected coins together with the amount of change to send back to yourself, taking the fee into account. This function assumes all the coins are script hash outputs that send funds to a multisignature address.
:: Int | Number of regular transaction inputs. |
-> [(Int, Int)] | For every multisig input in the transaction, provide the multisig parameters m of n (m,n) for that input. |
-> Int | Number of pay to public key hash outputs. |
-> Int | Number of pay to script hash outputs. |
-> Int | Upper bound on the transaction size. |
Computes an upper bound on the size of a transaction based on some known properties of the transaction.