FLAPX Ruby on rails API client is a gem that makes it easy to work with Litedoge in ruby.
The only requirement is a running FlapXcoin daemon (flapxcoind). Make sure to check out the doc section and follow the instructions for your os. NOTICE: by default flapxcoind will only allow local connections.
Add this line to your application's Gemfile:
gem 'flapx_client'
Or install it yourself as:
$ gem install flapx_client
If you're using rails you can create an initializer. Here are the default settings:
# config/initializers/flapx_ruby-client.rb
flapx_ruby-client.configure do |config|
config.host = 'localhost'
config.port = 60142
config.protocol = :http
config.user = ''
config.password = ''
end
You can also pass config variables as an options hash when creating a new client:
client = flapx_ruby-client.new(user: 'my_flapxd_username', password: 'my_super_secure_password')
# create a new instance of the client
client = flapx_client.new
# check that flapxcoind 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} FLAPX!"
else
puts 'Something is wrong...'
end
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 FLAPX 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 | [FLAPXaddress] | Reveals the private key corresponding to | Yes |
encrypt_wallet | [passphrase] | Encrypts the wallet with | No |
get_account | [FLAPXaddress] | Returns the account associated with the given address. | No |
get_account_address | [account] | Returns the current flapxcoin 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 litedoged 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:
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:
|
No | |
get_new_address | [account] | Returns a new flapxcoin 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. | No |
get_received_by_address | [litedogeaddress] [minconf=1] | Returns the total amount received by | No |
get_transaction | [txid] | Returns an object about the given transaction containing:
|
No |
get_work | [data] | If [data] is not specified, returns formatted hash data to work on:
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 | [FLAPXprivkey] [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:
|
No |
list_received_by_address | [minconf=1] [includeempty=false] | Returns an array of objects containing:
To get a list of accounts on the system, execute litedoged 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] [toFLAPXaddress] [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 | [FLAPXaddress] [amount] [comment] [comment-to] | Yes | |
set_account | [FLAPXaddress] [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 | [FLAPXaddress] [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 FlapXCoin server. | No | |
validate_address | [FLAPXaddress] | Return information about [FLAPXaddress]. | No |
verify_message | [FLAPXaddress] [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
For local testing, make sure to replace the user/password in spec/client_spec.rb
and spec/flapx_client _spec.rb
with the credentials for your local flapxcoind.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Perhaps, but this way you don't need to worry about any current or future api inconsistencies.