Skip to content

A DogecoinDark client for ruby. A wrapper gem for making remote procedure calls to dogecoindarkd.

License

Notifications You must be signed in to change notification settings

doged/doged-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

doged-ruby

The DogecoinDark Ruby Client

The DogecoinDark Ruby Client is a gem that makes it easy to work with dogecoin in ruby.

Dependencies

The only requirement is a running dogecoindark daemon (dogecoindarkd). NOTICE: by default dogecoindarkd will only allow local connections.

Installation

Add this line to your application's Gemfile:

gem 'dogecoindark_client'

Or install it yourself as:

$ gem install dogecoindark_client

Configuration

If you're using rails you can create an initializer. Here are the default settings:

# config/initializers/dogecoindark_client.rb
DogecoinDarkClient.configure do |config|
    config.host = 'localhost'
    config.port = 20102
    config.protocol = :http
    config.user = 'dogecoindarkrpcuser'
    config.password = 'rpcpasswordhere'
end

You can also pass config variables as an options hash when creating a new client:

client = DogecoinDarkClient.new(user: 'my_dogecoindarkd_username', password: 'my_super_secure_password')

Example Usage

# create a new instance of the client
client = DogecoinDarkClient.new

# check that dogecoindarkd 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} doged!"
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 [dogecoindarkaddress] Reveals the private key corresponding to Yes
encrypt_wallet [passphrase] Encrypts the wallet with No
get_account [dogecoindarkaddress] Returns the account associated with the given address. No
get_account_address [account] Returns the current dogecoindark 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 dogecoindarkd 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 dogecoindark 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 [dogecoindarkaddress] [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"
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 dogecoindarkd 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] [todogecoindarkaddress] [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 [dogecoindarkaddress] [amount] [comment] [comment-to] Yes
set_account [dogecoindarkaddress] [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 [dogecoindarkaddress] [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 dogecoindark server. No
validate_address [dogecoindarkaddress] Return information about [dogecoindarkaddress]. No
verify_message [dogecoindarkaddress] [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

Contributing

For local testing, make sure to replace the user/password in spec/client_spec.rb and spec/dogecoindark_client_spec.rb with the credentials for your local dogecoindarkd.

  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?

About

A DogecoinDark client for ruby. A wrapper gem for making remote procedure calls to dogecoindarkd.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%