-
Notifications
You must be signed in to change notification settings - Fork 104
Plugins
Plugins are part of lamassu-server
(version 1.0.1 and up) functionality that can be implemented by a 3rd party.
Each plugin MUST publically expose following fields:
-
NAME
-String
containing formatted name of the plugin (example) -
SUPPORTED_MODULES
-Array
containing list of supported pludin types (exawple)
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 plugin's README file.
Each plugin package can implement multiple plugin types. Bitstamp
plugin is an example 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
Strings
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 be eitherString
or an instance of anError
object, -
callbackReturnValue
is different for each method and will be defined in it's 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 limit orders when price is provided. Lack of limit orders 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 limit orders when price is provided. Lack of limit orders 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
Should return 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
- Timestamp when tx was first spotted, -
confirmations
-Integer
- Number of confirmations/blocks, -
amount
-Integer
- Amount transferred TO the given address, -
fees
-Integer
- Fees for miners included in this tx.
-
Should return current confirmation status for a given Transaction.
-
txHash
-String
containing hash of checked Transaction, -
callbackReturnValue
- anObject
with following fields:-
status
-String
containing one of the states listed below, -
confirmations
-Integer
number of confirmations for a given tx; required only inconfirmedDeposit
state, -
confidence
-Float
number between 0 and 1 indicating confidence level forauthorizedDeposit
status (1 being very sure).
-
Possible transaction statuses:
-
confirmedDeposit
- (required) reported when transaction has at least 1 confirmation, -
authorizedDeposit
- (optional) 0-confirmation; Relies on plugin-specific heuristics. Whenever this state is reported,confidence
field must be provided as well, -
fullDeposit
- (required) reported for 0-conf. txs, whenauthorizedDeposit
was not detected or is not implemented. In this case it's allowed to just call parameterlesscallback();
.