https://github.com/repp/dogecoin_client
A Dogecoin client for ruby. A wrapper gem for making remote procedure calls to dogecoind.
https://github.com/repp/dogecoin_client
Last synced: 4 months ago
JSON representation
A Dogecoin client for ruby. A wrapper gem for making remote procedure calls to dogecoind.
- Host: GitHub
- URL: https://github.com/repp/dogecoin_client
- Owner: repp
- License: mit
- Created: 2014-02-23T20:13:07.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-31T03:13:21.000Z (about 12 years ago)
- Last Synced: 2026-01-01T09:32:35.221Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 180 KB
- Stars: 17
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DogecoinClient
DogecoinClient is a gem that makes it easy to work with dogecoin in ruby.
## Dependencies
The only requirement is a running dogecoin daemon ([dogecoind](https://github.com/dogecoin/dogecoin)). Make sure to check out the [doc section](https://github.com/dogecoin/dogecoin/tree/master/doc) and follow the instructions for your os.
NOTICE: by default dogecoind will only allow local connections.
## Installation
Add this line to your application's Gemfile:
gem 'dogecoin_client'
Or install it yourself as:
$ gem install dogecoin_client
## Configuration
If you're using rails you can create an initializer. Here are the default settings:
```ruby
# config/initializers/dogecoin_client.rb
DogecoinClient.configure do |config|
config.host = 'localhost'
config.port = 22555
config.protocol = :http
config.user = ''
config.password = ''
end
```
You can also pass config variables as an options hash when creating a new client:
```ruby
client = DogecoinClient.new(user: 'my_dogecoind_username', password: 'my_super_secure_password')
```
## Example Usage
```ruby
# create a new instance of the client
client = DogecoinClient.new
# check that dogecoind is running and that our credentials are correct
if client.valid?
# get a new wallet address
new_wallet_addr = client.get_new_address
# get the balance of our new wallet
my_balance = client.get_balance(new_wallet_addr)
puts "I have #{my_balance} doge!"
else
puts 'Something is wrong...'
end
```
## Available Methods
Method
Params
Description
unlckd wallet req?
add_multi_sig_address
[nrequired] ["key","key"] [account]
Currently only available on testnet Add a nrequired-to-sign multisignature address to the wallet. Each key is a dogecoin address or hex-encoded public key. If [account] is specified, assign address to [account].
No
backup_wallet
[destination]
Safely copies wallet.dat to destination, which can be a directory or a path with filename.
No
dump_priv_key
[dogecoinaddress]
Reveals the private key corresponding to
Yes
encrypt_wallet
[passphrase]
Encrypts the wallet with
No
get_account
[dogecoinaddress]
Returns the account associated with the given address.
No
get_account_address
[account]
Returns the current dogecoin address for receiving payments to this account.
No
get_addresses_by_account
[account]
Returns the list of addresses for the given account.
No
get_balance
[account] [minconf=1]
If [account] is not specified, returns the server's total available balance.
If [account] is specified, returns the balance in the account.
No
get_block
[hash]
Returns information about the given block hash.
No
get_block_count
Returns the number of blocks in the longest block chain.
No
get_block_hash
[index]
Returns hash of block in best-block-chain at
No
get_block_number
Deprecated. Use getblockcount.
No
get_connection_count
Returns the number of connections to other nodes.
No
get_difficulty
Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
No
get_generate
Returns true or false whether dogecoind is currently generating hashes
No
get_hashes_per_sec
Returns a recent hashes per second performance measurement while generating.
No
get_info
Returns an object containing various state info.
No
get_memory_pool
[data]
If [data] is not specified, returns data needed to construct a block to work on:
- "version": block version
- "previousblockhash": hash of current highest block
- "transactions": contents of non-coinbase transactions that should be included in the next block
- "coinbasevalue": maximum allowable input to coinbase transaction, including the generation award and transaction fees
- "time": timestamp appropriate for next block
- "bits": compressed target of next block
If [data] is specified, tries to solve the block and returns true if it was successful.
No
get_mining_info
Returns an object containing mining-related information:
- blocks
- currentblocksize
- currentblocktx
- difficulty
- errors
- generate
- genproclimit
- hashespersec
- pooledtx
- testnet
No
get_new_address
[account]
Returns a new dogecoin address for receiving payments. If [account] is specified (recommended), it is added to the address book so payments received with the address will be credited to [account].
No
get_received_by_account
[account] [minconf=1]
Returns the total amount received by addresses with [account] in transactions with at least [minconf] confirmations. If [account] not provided return will include all transactions to all accounts. (version 0.3.24-beta)
No
get_received_by_address
[dogecoinaddress] [minconf=1]
Returns the total amount received by
No
get_transaction
[txid]
Returns an object about the given transaction containing:
- "amount": total amount of the transaction
- "confirmations": number of confirmations of the transaction
- "txid": the transaction ID
- "time": time the transaction occurred
- "details" - An array of objects containing:
- "account"
- "address"
- "category"
- "amount"
- "account"
No
get_work
[data]
If [data] is not specified, returns formatted hash data to work on:
- "midstate": precomputed hash state after hashing the first half of the data
- "data": block data
- "hash1": formatted hash buffer for second hash
- "target": little endian hash target
If [data] is specified, tries to solve the block and returns true if it was successful.
No
help
[command]
List commands, or get help for a command.
No
import_priv_key
[dogecoinprivkey] [label]
Adds a private key (as returned by dumpprivkey) to your wallet.
Yes
key_pool_refill
Fills the keypool, requires wallet passphrase to be set.
Yes
list_accounts
[minconf=1]
Returns Object that has account names as keys, account balances as values.
No
list_received_by_account
[minconf=1] [includeempty=false]
Returns an array of objects containing:
- "account": the account of the receiving addresses
- "amount": total amount received by addresses with this account
- "confirmations": number of confirmations of the most recent transaction included
No
list_received_by_address
[minconf=1] [includeempty=false]
Returns an array of objects containing:
- "address": receiving address
- "account": the account of the receiving address
- "amount": total amount received by the address
- "confirmations": number of confirmations of the most recent transaction included
To get a list of accounts on the system, execute dogecoind listreceivedbyaddress 0 true
No
list_since_block
[blockhash] [target-confirmations]
Get all transactions in blocks since block [blockhash], or all transactions if omitted.
No
list_transactions
[account] [count=10] [from=0]
Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]. If [account] not provided will return recent transaction from all accounts.
No
move
[fromaccount] [toaccount] [amount] [minconf=1] [comment]
Move from one account in your wallet to another
No
send_from
[fromaccount] [todogecoinaddress] [amount] [minconf=1] [comment] [comment-to]
Yes
send_many
[fromaccount] [address:amount,...] [minconf=1] [comment]
amounts are double-precision floating point numbers
Yes
send_to_address
[dogecoinaddress] [amount] [comment] [comment-to]
Yes
set_account
[dogecoinaddress] [account]
Sets the account associated with the given address. Assigning address that is already assigned to the same account will create a new address associated with that account.
No
set_generate
[generate] [genproclimit]
[generate] is true or false to turn generation on or off.
Generation is limited to [genproclimit] processors, -1 is unlimited.
No
sign_message
[dogecoinaddress] [message]
Sign a message with the private key of an address.
Yes
set_tx_fee
[amount]
[amount] is a real and is rounded to the nearest 0.00000001
No
stop
Stop dogecoin server.
No
validate_address
[dogecoinaddress]
Return information about [dogecoinaddress].
No
verify_message
[dogecoinaddress] [signature] [message]
Verify a signed message.
No
wallet_lock
Removes the wallet encryption key from memory, locking the wallet. After calling this method, you will need to call walletpassphrase again before being able to call any methods which require the wallet to be unlocked.
No
wallet_passphrase
[passphrase] [timeout]
Stores the wallet decryption key in memory for
No
wallet_passphrase_change
[oldpassphrase] [newpassphrase]
Changes the wallet passphrase from
No
*Table stolen from [node-dogecoin](https://github.com/countable/node-dogecoin)
## Contributing
For local testing, make sure to replace the user/password in `spec/client_spec.rb` and `spec/dogecoin_client_spec.rb` with the credentials for your local dogecoind.
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Can't I just use a client for bitcoin or litecoin?
Perhaps, but this way you don't need to worry about any current or future api inconsistencies. Plus, why use a tool built for an inferior alt coin?