OTC is a daemon with the sole purpose of exposing an HTTP API that allows users to exchange a variety of currencies (BTC, ETH, etc.) for Skycoin (and others in the future).
- start skycoin node
$ cd github.com/skycoin/skycoin
$ make run
- start btcwallet node (requires btcd but for testing you don't need that)
$ ./btcwallet -u otc -P OTC
NOTES: If you don't have BTC wallet you should create a new one using following command
$ ./btcwallet -u username -P passphrase --create
- start otc
NOTES:
- seed - seed of the new SkyCoin wallet
- account - passphrase of BTC wallet certificate
$ cd github.com/skycoin-karl/services/otc
$ go build
$ ./otc
OTC's frontend is exposed as an HTTP API.
This creates a new request in the backend and returns JSON output on the frontend. The user can then send their currency to the returned address and the process will begin.
http request
{
"address": "...skycoin address...",
"drop_currency": "BTC",
"affiliate": "...affiliate code..."
}addressis the user's skycoin address where skycoin will be delivereddrop_currencydetermines the type ofdrop_addressto generate (what currency the user wants to deposit)affiliateis the affiliate code to associate with this bind event (most likely stored in the users cookies)
http response
{
"drop_address": "...",
"drop_currency": "BTC",
"drop_value": 159900
}drop_addressis the address of typedrop_currencyfor the user to send their currency todrop_currencyis the same as sent in the requestdrop_valueis the current price of 1 SKY in terms ofdrop_currency- represented as satoshis, example: 159900 = 0.00159900 BTC
This gets the metadata of a request and returns it to the user.
http request
{
"drop_address": "...",
"drop_currency": "..."
}
drop_addressdenotes the address they want the status ofdrop_currencydenotes the currency of the address they want the status of
http response
{
"status": "...",
"updated_at": 1519131184
}
statusis one of the following:waiting_deposit- skycoin address is bound, no deposit seen yetwaiting_send- deposit detected, waiting to send to userwaiting_confirm- skycoin sent, waiting to confirm transactiondone- skycoin transaction confirmedexpired- drop expired
updated_atis the unix time (seconds) when the request was last updated
Returns amount of BTC held in deposit addresses generated by OTC.
{
"holding": 150000000
}150000000 = 1.5 BTC
Returns list of addresses for the OTC SKY wallet with their balance. Note that no filtering is done, so many addresses may be included with 0 balance.
[
{
"address": "tmZpWYHPVUxmXr7VFEBV7pvMTaQJYCC5op",
"balance": 45200000
},
{
"address": "2ULeXgdJ2KytrARaGxtPNZxw2rByWfKEH3j",
"balance": 0
}
]45200000 = 45.2 SKY
Get status of OTC.
http request
Nothing, just a GET.
http response
{
"prices": {
"internal": 150000,
"internal_updated": 1519131184,
"exchange": 119833,
"exchange_updated": 1519131184
},
"source": "internal",
"paused": true
}Set the price of internal source.
http request
{
"price": 119833
}priceis the satoshi value of 1 SKY.119833is equal to0.00119833 BTC.
Set the price source.
http request
{
"source": "exchange"
}sourceis eitherexchangeto get pricing from an exchange, orinternalto use the manually setinternalprice
Pause state transitions.
http request
{
"pause": true
}pauseis a boolean denoting whether to pause or not
{
"address": "2dvVgeKNU7UHdvvBUVZXbBaxoTkpemo1cmg",
"status": "waiting_confirm",
"txid": "acfc6bd9e5b0b8eca1dad7e393658b51f01eda0f961a6b336a130ebc752565b8",
"rate": {
"value": 150000,
"source": "internal"
},
"drop": {
"address": "mnum2BxQ47qERaGtyfShAG1wkzJhhJE2J2",
"currency": "BTC",
"amount": 50000000
},
"timestamps": {
"created_at": 1519131184,
"deposited_at": 1519131200,
"sent_at": 1519131500,
"updated_at": 1519131500
}
}addressis the destination skycoin addressstatusis one of the status codes for the entire transactiontxidis the txid of the otc->user skycoin transaction (final step)ratecontains information about the rate used when skycoin was sent to the uservalueis the value of 1 SKY in the drop currency (150000is0.00150000 BTCin this example)sourcedenotes which rate source was used (eitherexchangeorinternalfor now)
dropcontains information about the deposit address (the "drop")addressis the address being scanned for depositcurrencydenotes the currency of the drop (currently just BTC)amountdenotes the amount of drop currency received (50000000is0.50000000 BTCin this example)
timestampscontains unix times of each stepcreated_atis when the transaction was createddeposited_atis when the deposit was detectedsent_atis when the skycoin was sent to the userupdated_atis the last time the request was updated and saved to disk
Returns all transactions.
[
{transaction},
{transaction}...
]
Returns uncompleted transactions.
[
{transaction},
{transaction}...
]
Returns created transactions.
[
{transaction},
{transaction}...
]