Safe Haskell | None |
---|
An interface to bitcoind's available wallet-related RPC calls. The implementation of these functions can be found at https://github.com/bitcoin/bitcoin/blob/master/src/rpcwallet.cpp.
If any APIs are missing, patches are always welcome. If you look at the source of this module, you'll see that the interface code is trivial.
Certain APIs were too complicated for me to write an interface for. If you figure them out, then patches are always welcome! They're left in the source as comments.
- data Auth = Auth {}
- data BitcoindInfo = BitcoindInfo {
- bitcoinVersion :: Integer
- protocolVersion :: Integer
- walletVersion :: Integer
- balance :: BTC
- numBlocks :: Integer
- numConnections :: Integer
- proxy :: Text
- generationDifficulty :: Double
- onTestNetwork :: Bool
- keyPoolOldest :: Integer
- keyPoolSize :: Integer
- transactionFeePaid :: BTC
- unlockedUntil :: Maybe Integer
- bitcoindErrors :: Text
- getBitcoindInfo :: Auth -> IO BitcoindInfo
- getNewAddress :: Auth -> Maybe Account -> IO Address
- getAccountAddress :: Auth -> Account -> IO Address
- getAccount :: Auth -> Address -> IO Account
- setAccount :: Auth -> Address -> Account -> IO ()
- getAddressesByAccount :: Auth -> Account -> IO (Vector Address)
- sendToAddress :: Auth -> Address -> BTC -> Maybe Text -> Maybe Text -> IO TransactionID
- data AddressInfo = AddressInfo {}
- listAddressGroupings :: Auth -> IO (Vector (Vector AddressInfo))
- type Signature = HexString
- signMessage :: Auth -> Address -> Text -> IO Signature
- verifyMessage :: Auth -> Address -> Signature -> Text -> IO Bool
- getReceivedByAddress :: Auth -> Address -> IO BTC
- getReceivedByAddress' :: Auth -> Address -> Int -> IO BTC
- getReceivedByAccount :: Auth -> Account -> IO BTC
- getReceivedByAccount' :: Auth -> Account -> Int -> IO BTC
- getBalance :: Auth -> IO BTC
- getBalance' :: Auth -> Account -> IO BTC
- getBalance'' :: Auth -> Account -> Int -> IO BTC
- moveBitcoins :: Auth -> Account -> Account -> BTC -> Text -> IO ()
- sendFromAccount :: Auth -> Account -> Address -> BTC -> Maybe Text -> Maybe Text -> IO TransactionID
- sendMany :: Auth -> Account -> Vector (Address, BTC) -> Maybe Text -> IO TransactionID
- data ReceivedByAddress = ReceivedByAddress {}
- listReceivedByAddress :: Auth -> IO (Vector ReceivedByAddress)
- listReceivedByAddress' :: Auth -> Int -> Bool -> IO (Vector ReceivedByAddress)
- data ReceivedByAccount = ReceivedByAccount {}
- listReceivedByAccount :: Auth -> IO (Vector ReceivedByAccount)
- listReceivedByAccount' :: Auth -> Int -> Bool -> IO (Vector ReceivedByAccount)
- backupWallet :: Auth -> FilePath -> IO ()
- keyPoolRefill :: Auth -> IO ()
- unlockWallet :: Auth -> Text -> Integer -> IO ()
- lockWallet :: Auth -> IO ()
- changePassword :: Auth -> Text -> Text -> IO ()
- encryptWallet :: Auth -> Text -> IO ()
- isAddressValid :: Auth -> Address -> IO Bool
Documentation
data BitcoindInfo Source
A plethora of information about a bitcoind instance.
BitcoindInfo | |
|
getBitcoindInfo :: Auth -> IO BitcoindInfoSource
Returns an object containing various state info.
getNewAddress :: Auth -> Maybe Account -> IO AddressSource
Returns a new bitcoin address for receiving payments.
If an account is specified (recommended), the new address is added to the address book so payments received with the address will be credited to the given account.
If no account is specified, the address will be credited to the account whose name is the empty string. i.e. the default account.
getAccountAddress :: Auth -> Account -> IO AddressSource
Returns the current Bitcoin address for receiving payments to the given account.
getAccount :: Auth -> Address -> IO AccountSource
Returns the account associated with the given address.
setAccount :: Auth -> Address -> Account -> IO ()Source
Sets the account associated with the given address.
getAddressesByAccount :: Auth -> Account -> IO (Vector Address)Source
Returns the list of addresses for the given address.
:: Auth | |
-> Address | Who we're sending to. |
-> BTC | The amount to send. |
-> Maybe Text | An optional comment for the transaction. |
-> Maybe Text | An optional comment-to (who did we sent this to?) for the transaction. |
-> IO TransactionID |
Sends some bitcoins to an address.
data AddressInfo Source
Information on a given address.
Eq AddressInfo | |
Ord AddressInfo | |
Read AddressInfo | |
Show AddressInfo | |
FromJSON AddressInfo | What a silly API. |
listAddressGroupings :: Auth -> IO (Vector (Vector AddressInfo))Source
Lists groups of addresses which have had their common ownership made public by common use as inputs or as the resulting change in past transactions.
:: Auth | |
-> Address | The address whose private key we'll use. |
-> Text | The message to sign. |
-> IO Signature |
Sign a message with the private key of an address.
:: Auth | |
-> Address | The address of the original signer. |
-> Signature | The message's signature. |
-> Text | The message. |
-> IO Bool | Was the signature valid? |
Verifies a signed message.
getReceivedByAddress :: Auth -> Address -> IO BTCSource
Returns the total amount received by the given address with at least one confirmation.
:: Auth | |
-> Address | |
-> Int | The minimum number of confirmations needed for a transaction to to count towards the total. |
-> IO BTC |
Returns the total amount received by the given address, with at least the give number of confirmations.
getReceivedByAccount :: Auth -> Account -> IO BTCSource
Returns the total amount received by address with the given account.
:: Auth | |
-> Account | The account in question. |
-> Int | The minimum number of confirmations needed for a transaction to count towards the total. |
-> IO BTC |
Returns the total amount received by addresses with the given account, counting only transactions with the given minimum number of confirmations.
getBalance :: Auth -> IO BTCSource
Returns the server's total available balance.
getBalance' :: Auth -> Account -> IO BTCSource
Returns the balance in the given account, counting only transactions with at least one confirmation.
:: Auth | |
-> Account | |
-> Int | The minimum number of confirmations needed for a transaction to count towards the total. |
-> IO BTC |
Returns the balance in the given account, counting only transactions with at least the given number of confirmations.
:: Auth | |
-> Account | From. |
-> Account | To. |
-> BTC | The amount to transfer. |
-> Text | A comment to record for the transaction. |
-> IO () |
Move bitcoins from one account in your wallet to another.
If you want to send bitcoins to an address not in your wallet, use
sendFromAccount
.
:: Auth | |
-> Account | The account to send from. |
-> Address | The address to send to. |
-> BTC | The amount to send. |
-> Maybe Text | An optional transaction comment. |
-> Maybe Text | An optional comment on who the money is going to. |
-> IO TransactionID |
Sends bitcoins from a given account in our wallet to a given address.
A transaction and sender comment may be optionally provided.
:: Auth | |
-> Account | The account to send from. |
-> Vector (Address, BTC) | The address, and how much to send to each one. |
-> Maybe Text | An optional transaction comment. |
-> IO TransactionID |
Send to a whole bunch of address at once.
data ReceivedByAddress Source
Information on how much was received by a given address.
ReceivedByAddress | |
|
listReceivedByAddress :: Auth -> IO (Vector ReceivedByAddress)Source
Lists the amount received by each address which has received money at some point, counting only transactions with at least one confirmation.
:: Auth | |
-> Int | The minimum number of confirmations before a transaction counts toward the total amount received. |
-> Bool | Should we include addresses with no money received? |
-> IO (Vector ReceivedByAddress) |
List the amount received by each of our addresses, counting only transactions with the given minimum number of confirmations.
data ReceivedByAccount Source
ReceivedByAccount | |
|
listReceivedByAccount :: Auth -> IO (Vector ReceivedByAccount)Source
Lists the amount received by each account which has received money at some point, counting only transactions with at leaset one confirmation.
:: Auth | |
-> Int | The minimum number of confirmations before a transaction counts toward the total received. |
-> Bool | Should we include the accounts with no money received? |
-> IO (Vector ReceivedByAccount) |
List the amount received by each of our accounts, counting only transactions with the given minimum number of confirmations.
backupWallet :: Auth -> FilePath -> IO ()Source
Safely copies wallet.dat to the given destination, which can be either a directory, or a path with filename.
keyPoolRefill :: Auth -> IO ()Source
Fills the keypool.
:: Auth | |
-> Text | The decryption key. |
-> Integer | How long to store the key in memory (in seconds). |
-> IO () |
Stores the wallet decryption key in memory for the given amount of time.
lockWallet :: Auth -> IO ()Source
Removes the wallet encryption key from memory, locking the wallet.
After calling this function, you will need to call unlockWallet
again
before being able to call methods which require the wallet to be unlocked.
Note: In future releases, we might introduce an unlocked monad, so locking and unlocking is automatic.
Changes the wallet passphrase.
encryptWallet :: Auth -> Text -> IO ()Source
Encrypts the wallet with the given passphrase.
WARNING: bitcoind will shut down after calling this method. Don't say I didn't warn you.