-
Notifications
You must be signed in to change notification settings - Fork 104
Plugins
Plugins are a part of lamassu-server
(version 1.0.1 and up) functionality that can be implemented by a 3rd party.
Each plugin MUST publicly expose the following fields:
-
NAME
-String
containing a formatted name of the plugin (example) -
SUPPORTED_MODULES
-Array
containing a list of supported plugin types (example)
All plugins depending on an external configuration (credentials, global currency, etc.) SHOULD expose config(Object config)
method (example). Each plugin may specify it's own flat JSON configuration scheme. This scheme should be documented in the plugin's README file.
Each plugin package can implement multiple plugin types. Bitstamp
plugin is an example of implementing both Ticker
and Trader
.
On server boot, all plugins are loaded (require('plugin-name');
) and configured (plugin.config(configObject);
). Once plugins configuration changes plugin's .config()
method is called, and that may happen any time.
-
All Bitcoin values are passed in Satoshis as an
Integer
, -
All fiat values are passed as a
String
with 2 decimal places, -
All
callback
s have the following structure (unless otherwise noted):function calback(error, callbackReturnValue) { // further processing }
where
error
andcallbackReturnValue
are mutually exclusive, and:-
error
can either be aString
or an instance of anError
object, -
callbackReturnValue
is different for each method and will be defined in its description.
-
Sends Bitcoins, generates new Bitcoin addresses, returns its current balance.
Plugin type (for SUPPORTED_MODULES
array): wallet
Example: lamassu-blockchain
Creates and broadcasts transaction for a given Bitcoin amount and to a given Bitcoin address.
-
address
-String
containing Bitcoin address in Base58 format, -
satoshis
-Integer
amount to be sent, -
minersFee
-Integer
amount to be used as a fee, -
callbackReturnValue
-String
transaction hash of a sent tx.
Returns balance available for sending (funds with at least 1 confirmation).
-
callbackReturnValue
-Object
mapping ALL CAPS currency codes (ex.BTC
) to theirInteger
satoshi values.
Generates and stores private key of a new Bitcoin address.
-
info
-Object
containing two fields (supporting them is optional):-
label
-String
should be used to name generated address (if supported), -
account
-String
name of wallet account to be used (if supported).
-
-
callbackReturnValue
-String
containing Bitcoin address in Base58 format,
Provides current Bitcoin price for a given currency or currencies.
Plugin type: ticker
Example: lamassu-bitstamp
Returns current ask and bid prices for a given currency/currencies.
-
currencies
-String
orArray
ofString
s of currencies to be checked, -
callbackReturnValue
-Object
mapping ALL CAPS currency codes (ex.USD
) to objects with the following structure:{ USD: { currency: 'USD', rates: { ask: String, // two decimal places bid: String // two decimal places } } }
Conducts instant market buys/sells for a given BTC amount.
Plugin type: trader
Example: lamassu-bitstamp
Returns available balance for both virtual and fiat currencies.
-
callbackReturnValue
-Object
mapping ALL CAPS currency codes (ex.BTC
orUSD
) to their values. For their formats see Plugin patterns.
MUST by default place market-buy orders and should fall back to a limit order when price is provided. Lack of limit orders support should be noted in repository README file.
-
satoshis
-Integer
amount of satoshis to be purchased, -
opts
-Object
currently the only allowed parameter here is an optionalprice
.
This method should only return error on failure, no
callbackReturnValue
is required!
MUST by default place market-sell orders and should fall back to a limit order when price is provided. Lack of limit orders support should be noted in repository README file.
-
satoshis
-Integer
amount of satoshis to be purchased, -
opts
-Object
currently the only allowed parameter here is an optionalprice
.
This method should only return error on failure, no
callbackReturnValue
is required!
Verifies users and transactions.
Plugin type: idVerifier
Example: lamassu-identitymind
Provides server with public ledger data (ex. tx status, address's txs, address balance)
Plugin type: info
Example: lamassu-chain
Returns data about last incoming tx for a given address.
-
address
-String
containing Bitcoin address in Base58 format, -
callbackReturnValue
- anObject
with following fields:-
txHash
-String
- Transaction hash, -
tsReceived
-Integer
- UNIX timestamp when tx was first spotted, -
confirmations
-Integer
- Number of confirmations/blocks, -
amount
-Integer
- Amount by which address balance changed, -
fees
-Integer
- Fees for miners included in this tx, -
authorized
-Boolean
- Should be set when plugin implements own 0-confirmations heuristics, -
confidence
-Flat
- Number between 0 and 1 indicating confidence level forauthorized
status (1 being very sure).
-
Returns current confirmation status for a given Transaction.
-
txHash
-String
containing hash of checked Transaction, -
address
-String
containing Bitcoin address in Base58 format, -
callbackReturnValue
- the same as in.getAddressLastTx()
method.