|
|
|
|
@@ -122,13 +122,13 @@ func (l *LocalBitcoins) GetAccountInformation(username string, self bool) (Accou
|
|
|
|
|
resp := response{}
|
|
|
|
|
|
|
|
|
|
if self {
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIMyself, nil, &resp)
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPIMyself, nil, &resp)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return resp.Data, err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
path := fmt.Sprintf("%s/%s/%s/", l.API.Endpoints.URL, localbitcoinsAPIAccountInfo, username)
|
|
|
|
|
err := l.SendHTTPRequest(path, &resp, request.Unset)
|
|
|
|
|
path := fmt.Sprintf("/%s/%s/", localbitcoinsAPIAccountInfo, username)
|
|
|
|
|
err := l.SendHTTPRequest(exchange.RestSpot, path, &resp, request.Unset)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return resp.Data, err
|
|
|
|
|
}
|
|
|
|
|
@@ -152,14 +152,14 @@ func (l *LocalBitcoins) Getads(args ...string) (AdData, error) {
|
|
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
if len(args) == 0 {
|
|
|
|
|
err = l.SendAuthenticatedHTTPRequest(http.MethodGet,
|
|
|
|
|
err = l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet,
|
|
|
|
|
localbitcoinsAPIAds,
|
|
|
|
|
nil,
|
|
|
|
|
&resp)
|
|
|
|
|
} else {
|
|
|
|
|
params := url.Values{"ads": {strings.Join(args, ",")}}
|
|
|
|
|
|
|
|
|
|
err = l.SendAuthenticatedHTTPRequest(http.MethodGet,
|
|
|
|
|
err = l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet,
|
|
|
|
|
localbitcoinsAPIAdGet,
|
|
|
|
|
params,
|
|
|
|
|
&resp)
|
|
|
|
|
@@ -189,7 +189,7 @@ func (l *LocalBitcoins) EditAd(_ *AdEdit, adID string) error {
|
|
|
|
|
}
|
|
|
|
|
}{}
|
|
|
|
|
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodPost,
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost,
|
|
|
|
|
localbitcoinsAPIAdEdit+adID+"/",
|
|
|
|
|
nil,
|
|
|
|
|
&resp)
|
|
|
|
|
@@ -209,7 +209,7 @@ func (l *LocalBitcoins) EditAd(_ *AdEdit, adID string) error {
|
|
|
|
|
// params - see localbitcoins_types.go AdCreate for reference
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) CreateAd(_ *AdCreate) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIAdCreate, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIAdCreate, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdatePriceEquation updates price equation of an advertisement. If there are
|
|
|
|
|
@@ -220,7 +220,7 @@ func (l *LocalBitcoins) CreateAd(_ *AdCreate) error {
|
|
|
|
|
// adID - string of specific ad identification
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) UpdatePriceEquation(adID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIUpdateEquation+adID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIUpdateEquation+adID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteAd deletes the advertisement by adID.
|
|
|
|
|
@@ -235,7 +235,7 @@ func (l *LocalBitcoins) DeleteAd(adID string) error {
|
|
|
|
|
} `json:"error"`
|
|
|
|
|
}{}
|
|
|
|
|
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodPost,
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost,
|
|
|
|
|
localbitcoinsAPIDeleteAd+adID+"/",
|
|
|
|
|
nil,
|
|
|
|
|
&resp)
|
|
|
|
|
@@ -253,7 +253,7 @@ func (l *LocalBitcoins) DeleteAd(adID string) error {
|
|
|
|
|
// ReleaseFunds releases Bitcoin trades specified by ID {contact_id}. If the
|
|
|
|
|
// release was successful a message is returned on the data key.
|
|
|
|
|
func (l *LocalBitcoins) ReleaseFunds(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIRelease+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIRelease+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ReleaseFundsByPin releases Bitcoin trades specified by ID {contact_id}. if
|
|
|
|
|
@@ -261,12 +261,12 @@ func (l *LocalBitcoins) ReleaseFunds(contactID string) error {
|
|
|
|
|
// returned on the data key.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) ReleaseFundsByPin(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIReleaseByPin+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIReleaseByPin+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MarkAsPaid marks a trade as paid.
|
|
|
|
|
func (l *LocalBitcoins) MarkAsPaid(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIMarkAsPaid+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIMarkAsPaid+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetMessages returns all chat messages from the trade. Messages are on the message_list key.
|
|
|
|
|
@@ -277,14 +277,14 @@ func (l *LocalBitcoins) GetMessages(contactID string) (Message, error) {
|
|
|
|
|
resp := response{}
|
|
|
|
|
|
|
|
|
|
return resp.MessageList,
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIMessages+contactID, nil, &resp)
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIMessages+contactID, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SendMessage posts a message and/or uploads an image to the trade. Encode
|
|
|
|
|
// images with multipart/form-data encoding.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) SendMessage(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPISendMessage+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPISendMessage+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Dispute starts a dispute on the specified trade ID if the requirements for
|
|
|
|
|
@@ -293,56 +293,56 @@ func (l *LocalBitcoins) SendMessage(contactID string) error {
|
|
|
|
|
// topic - [optional] String Short description of issue to LocalBitcoins customer support.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) Dispute(_, contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIDispute+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIDispute+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CancelTrade cancels the trade if the token owner is the Bitcoin buyer.
|
|
|
|
|
// Bitcoin sellers cannot cancel trades.
|
|
|
|
|
func (l *LocalBitcoins) CancelTrade(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICancelTrade+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPICancelTrade+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FundTrade attempts to fund an unfunded local trade from the token owners
|
|
|
|
|
// wallet. Works only if the token owner is the Bitcoin seller in the trade.
|
|
|
|
|
func (l *LocalBitcoins) FundTrade(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIFundTrade+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIFundTrade+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ConfirmRealName creates or updates real name confirmation.
|
|
|
|
|
func (l *LocalBitcoins) ConfirmRealName(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIConfirmRealName+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIConfirmRealName+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// VerifyIdentity marks the identity of trade partner as verified. You must be
|
|
|
|
|
// the advertiser in this trade.
|
|
|
|
|
func (l *LocalBitcoins) VerifyIdentity(contactID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIVerifyIdentity+contactID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIVerifyIdentity+contactID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// InitiateTrade sttempts to start a Bitcoin trade from the specified
|
|
|
|
|
// advertisement ID.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) InitiateTrade(adID string) error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIInitiateTrade+adID, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIInitiateTrade+adID, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetTradeInfo returns information about a single trade that the token owner is
|
|
|
|
|
// part in.
|
|
|
|
|
func (l *LocalBitcoins) GetTradeInfo(contactID string) (dbi DashBoardInfo, err error) {
|
|
|
|
|
err = l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPITradeInfo+contactID+"/", nil, &dbi)
|
|
|
|
|
err = l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPITradeInfo+contactID+"/", nil, &dbi)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetCountryCodes returns a list of valid and recognized countrycodes
|
|
|
|
|
func (l *LocalBitcoins) GetCountryCodes() error {
|
|
|
|
|
return l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPICountryCodes, nil, request.Unset)
|
|
|
|
|
return l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPICountryCodes, nil, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetCurrencies returns a list of valid and recognized fiat currencies. Also
|
|
|
|
|
// contains human readable name for every currency and boolean that tells if
|
|
|
|
|
// currency is an altcoin.
|
|
|
|
|
func (l *LocalBitcoins) GetCurrencies() error {
|
|
|
|
|
return l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPICurrencies, nil, request.Unset)
|
|
|
|
|
return l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPICurrencies, nil, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetDashboardInfo returns a list of trades on the data key contact_list. This
|
|
|
|
|
@@ -361,7 +361,7 @@ func (l *LocalBitcoins) GetDashboardInfo() ([]DashBoardInfo, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resp.Data.ContactList,
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboard, nil, &resp)
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPIDashboard, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetDashboardReleasedTrades returns a list of all released trades where the
|
|
|
|
|
@@ -375,7 +375,7 @@ func (l *LocalBitcoins) GetDashboardReleasedTrades() ([]DashBoardInfo, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resp.Data.ContactList,
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboardReleased, nil, &resp)
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPIDashboardReleased, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetDashboardCancelledTrades returns a list of all canceled trades where the
|
|
|
|
|
@@ -389,7 +389,7 @@ func (l *LocalBitcoins) GetDashboardCancelledTrades() ([]DashBoardInfo, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resp.Data.ContactList,
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboardCancelled, nil, &resp)
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPIDashboardCancelled, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetDashboardClosedTrades returns a list of all closed trades where the token
|
|
|
|
|
@@ -403,7 +403,7 @@ func (l *LocalBitcoins) GetDashboardClosedTrades() ([]DashBoardInfo, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resp.Data.ContactList,
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIDashboardClosed, nil, &resp)
|
|
|
|
|
l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPIDashboardClosed, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetFeedback gives feedback to user. Possible feedback values are: trust,
|
|
|
|
|
@@ -420,20 +420,20 @@ func (l *LocalBitcoins) GetDashboardClosedTrades() ([]DashBoardInfo, error) {
|
|
|
|
|
// username - username of trade contact
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) SetFeedback() error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIFeedback, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIFeedback, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Logout expires the current access token immediately. To get a new token
|
|
|
|
|
// afterwards, public apps will need to re-authenticate, confidential apps can
|
|
|
|
|
// turn in a refresh token.
|
|
|
|
|
func (l *LocalBitcoins) Logout() error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPILogout, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPILogout, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateNewInvoice creates a new invoice.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) CreateNewInvoice() error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICreateInvoice, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPICreateInvoice, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetInvoice returns information about a specific invoice created by the token
|
|
|
|
|
@@ -441,7 +441,7 @@ func (l *LocalBitcoins) CreateNewInvoice() error {
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) GetInvoice() (Invoice, error) {
|
|
|
|
|
resp := Invoice{}
|
|
|
|
|
return resp, l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICreateInvoice, nil, &resp)
|
|
|
|
|
return resp, l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPICreateInvoice, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteInvoice deletes a specific invoice. Deleting invoices is possible when
|
|
|
|
|
@@ -451,32 +451,32 @@ func (l *LocalBitcoins) GetInvoice() (Invoice, error) {
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) DeleteInvoice() (Invoice, error) {
|
|
|
|
|
resp := Invoice{}
|
|
|
|
|
return resp, l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPICreateInvoice, nil, &resp)
|
|
|
|
|
return resp, l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPICreateInvoice, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetNotifications returns recent notifications.
|
|
|
|
|
func (l *LocalBitcoins) GetNotifications() ([]NotificationInfo, error) {
|
|
|
|
|
var resp []NotificationInfo
|
|
|
|
|
return resp, l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIGetNotification, nil, &resp)
|
|
|
|
|
return resp, l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIGetNotification, nil, &resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MarkNotifications marks a specific notification as read.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) MarkNotifications() error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIMarkNotification, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIMarkNotification, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetPaymentMethods returns a list of valid payment methods. Also contains name
|
|
|
|
|
// and code for payment methods, and possible limitations in currencies and bank
|
|
|
|
|
// name choices.
|
|
|
|
|
func (l *LocalBitcoins) GetPaymentMethods() error {
|
|
|
|
|
return l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPIPaymentMethods, nil, request.Unset)
|
|
|
|
|
return l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPIPaymentMethods, nil, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetPaymentMethodsByCountry returns a list of valid payment methods filtered
|
|
|
|
|
// by countrycodes.
|
|
|
|
|
func (l *LocalBitcoins) GetPaymentMethodsByCountry(countryCode string) error {
|
|
|
|
|
return l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPIPaymentMethods+countryCode, nil, request.Unset)
|
|
|
|
|
return l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPIPaymentMethods+countryCode, nil, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CheckPincode checks the given PIN code against the token owners currently
|
|
|
|
|
@@ -494,7 +494,7 @@ func (l *LocalBitcoins) CheckPincode(pin int) (bool, error) {
|
|
|
|
|
resp := response{}
|
|
|
|
|
values := url.Values{}
|
|
|
|
|
values.Set("pincode", strconv.Itoa(pin))
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIPinCode, values, &resp)
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIPinCode, values, &resp)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
@@ -511,13 +511,13 @@ func (l *LocalBitcoins) CheckPincode(pin int) (bool, error) {
|
|
|
|
|
// sell listings for each.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) GetPlaces() error {
|
|
|
|
|
return l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPIPlaces, nil, request.Unset)
|
|
|
|
|
return l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPIPlaces, nil, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// VerifyUsername returns list of real name verifiers for the user. Returns a
|
|
|
|
|
// list only when you have a trade with the user where you are the seller.
|
|
|
|
|
func (l *LocalBitcoins) VerifyUsername() error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIVerifyUsername, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIVerifyUsername, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetRecentMessages returns maximum of 25 newest trade messages. Does not
|
|
|
|
|
@@ -525,7 +525,7 @@ func (l *LocalBitcoins) VerifyUsername() error {
|
|
|
|
|
// and the newest one is first.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) GetRecentMessages() error {
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIVerifyUsername, nil, nil)
|
|
|
|
|
return l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIVerifyUsername, nil, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetWalletInfo gets information about the token owner's wallet balance.
|
|
|
|
|
@@ -534,7 +534,7 @@ func (l *LocalBitcoins) GetWalletInfo() (WalletInfo, error) {
|
|
|
|
|
Data WalletInfo `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
resp := response{}
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIWallet, nil, &resp)
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPIWallet, nil, &resp)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return WalletInfo{}, err
|
|
|
|
|
@@ -555,7 +555,7 @@ func (l *LocalBitcoins) GetWalletBalance() (WalletBalanceInfo, error) {
|
|
|
|
|
Data WalletBalanceInfo `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
resp := response{}
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodGet, localbitcoinsAPIWalletBalance, nil, &resp)
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodGet, localbitcoinsAPIWalletBalance, nil, &resp)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return WalletBalanceInfo{}, err
|
|
|
|
|
@@ -594,7 +594,7 @@ func (l *LocalBitcoins) WalletSend(address string, amount float64, pin int64) er
|
|
|
|
|
} `json:"data"`
|
|
|
|
|
}{}
|
|
|
|
|
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodPost, path, values, &resp)
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, path, values, &resp)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
@@ -624,7 +624,7 @@ func (l *LocalBitcoins) GetWalletAddress() (string, error) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resp := response{}
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIWalletAddress, nil, &resp)
|
|
|
|
|
err := l.SendAuthenticatedHTTPRequest(exchange.RestSpot, http.MethodPost, localbitcoinsAPIWalletAddress, nil, &resp)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
@@ -639,22 +639,19 @@ func (l *LocalBitcoins) GetWalletAddress() (string, error) {
|
|
|
|
|
// GetBitcoinsWithCashAd returns buy or sell as cash local advertisements.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) GetBitcoinsWithCashAd() error {
|
|
|
|
|
return l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPICashBuy, nil, request.Unset)
|
|
|
|
|
return l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPICashBuy, nil, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetBitcoinsOnlineAd this API returns buy or sell Bitcoin online ads.
|
|
|
|
|
// TODO
|
|
|
|
|
func (l *LocalBitcoins) GetBitcoinsOnlineAd() error {
|
|
|
|
|
return l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPIOnlineBuy, nil, request.Unset)
|
|
|
|
|
return l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPIOnlineBuy, nil, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetTicker returns list of all completed trades.
|
|
|
|
|
func (l *LocalBitcoins) GetTicker() (map[string]Ticker, error) {
|
|
|
|
|
result := make(map[string]Ticker)
|
|
|
|
|
return result,
|
|
|
|
|
l.SendHTTPRequest(l.API.Endpoints.URL+localbitcoinsAPITicker,
|
|
|
|
|
&result,
|
|
|
|
|
tickerLimiter)
|
|
|
|
|
return result, l.SendHTTPRequest(exchange.RestSpot, localbitcoinsAPITicker, &result, tickerLimiter)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetTradableCurrencies returns a list of tradable fiat currencies
|
|
|
|
|
@@ -675,11 +672,9 @@ func (l *LocalBitcoins) GetTradableCurrencies() ([]string, error) {
|
|
|
|
|
// GetTrades returns all closed trades in online buy and online sell categories,
|
|
|
|
|
// updated every 15 minutes.
|
|
|
|
|
func (l *LocalBitcoins) GetTrades(currency string, values url.Values) ([]Trade, error) {
|
|
|
|
|
path := common.EncodeURLValues(fmt.Sprintf("%s%s/trades.json",
|
|
|
|
|
l.API.Endpoints.URL+localbitcoinsAPIBitcoincharts, currency),
|
|
|
|
|
values)
|
|
|
|
|
path := common.EncodeURLValues(fmt.Sprintf("%s%s/trades.json", localbitcoinsAPIBitcoincharts, currency), values)
|
|
|
|
|
var result []Trade
|
|
|
|
|
return result, l.SendHTTPRequest(path, &result, request.Unset)
|
|
|
|
|
return result, l.SendHTTPRequest(exchange.RestSpot, path, &result, request.Unset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetOrderbook returns buy and sell bitcoin online advertisements. Amount is
|
|
|
|
|
@@ -692,9 +687,9 @@ func (l *LocalBitcoins) GetOrderbook(currency string) (Orderbook, error) {
|
|
|
|
|
Asks [][]string `json:"asks"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path := l.API.Endpoints.URL + localbitcoinsAPIBitcoincharts + currency + "/orderbook.json"
|
|
|
|
|
path := fmt.Sprintf("%s/%s/orderbook.json", localbitcoinsAPIBitcoincharts, currency+"/orderbook.json")
|
|
|
|
|
resp := response{}
|
|
|
|
|
err := l.SendHTTPRequest(path, &resp, orderBookLimiter)
|
|
|
|
|
err := l.SendHTTPRequest(exchange.RestSpot, path, &resp, orderBookLimiter)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return Orderbook{}, err
|
|
|
|
|
@@ -734,10 +729,14 @@ func (l *LocalBitcoins) GetOrderbook(currency string) (Orderbook, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SendHTTPRequest sends an unauthenticated HTTP request
|
|
|
|
|
func (l *LocalBitcoins) SendHTTPRequest(path string, result interface{}, ep request.EndpointLimit) error {
|
|
|
|
|
func (l *LocalBitcoins) SendHTTPRequest(endpoint exchange.URL, path string, result interface{}, ep request.EndpointLimit) error {
|
|
|
|
|
ePoint, err := l.API.Endpoints.GetURL(endpoint)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return l.SendPayload(context.Background(), &request.Item{
|
|
|
|
|
Method: http.MethodGet,
|
|
|
|
|
Path: path,
|
|
|
|
|
Path: ePoint + path,
|
|
|
|
|
Result: result,
|
|
|
|
|
Verbose: l.Verbose,
|
|
|
|
|
HTTPDebugging: l.HTTPDebugging,
|
|
|
|
|
@@ -748,11 +747,14 @@ func (l *LocalBitcoins) SendHTTPRequest(path string, result interface{}, ep requ
|
|
|
|
|
|
|
|
|
|
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to
|
|
|
|
|
// localbitcoins
|
|
|
|
|
func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params url.Values, result interface{}) (err error) {
|
|
|
|
|
func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(ep exchange.URL, method, path string, params url.Values, result interface{}) (err error) {
|
|
|
|
|
if !l.AllowAuthenticatedRequest() {
|
|
|
|
|
return fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet, l.Name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
endpoint, err := l.API.Endpoints.GetURL(ep)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
n := l.Requester.GetNonce(true).String()
|
|
|
|
|
|
|
|
|
|
path = "/api/" + path
|
|
|
|
|
@@ -766,7 +768,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params
|
|
|
|
|
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
|
|
|
|
|
|
|
|
|
if l.Verbose {
|
|
|
|
|
log.Debugf(log.ExchangeSys, "Sending POST request to `%s`, path: `%s`, params: `%s`.", l.API.Endpoints.URL, path, encoded)
|
|
|
|
|
log.Debugf(log.ExchangeSys, "Sending POST request to `%s`, path: `%s`, params: `%s`.", endpoint, path, encoded)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if method == http.MethodGet && len(encoded) > 0 {
|
|
|
|
|
@@ -775,7 +777,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params
|
|
|
|
|
|
|
|
|
|
return l.SendPayload(context.Background(), &request.Item{
|
|
|
|
|
Method: method,
|
|
|
|
|
Path: l.API.Endpoints.URL + path,
|
|
|
|
|
Path: endpoint + path,
|
|
|
|
|
Headers: headers,
|
|
|
|
|
Body: bytes.NewBufferString(encoded),
|
|
|
|
|
Result: result,
|
|
|
|
|
|