add 3 new SDK calls
This commit is contained in:
parent
16f251b7f3
commit
c0a12af3ae
3 changed files with 122 additions and 1 deletions
|
@ -483,3 +483,28 @@ func (d *Client) ClaimAbandon(txID string, nOut int) (*ClaimAbandonResponse, err
|
|||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
//============================================
|
||||
// NEW SDK
|
||||
//============================================
|
||||
func (d *Client) AccountList() (*AccountListResponse, error) {
|
||||
response := new(AccountListResponse)
|
||||
return response, d.call(response, "account_list", map[string]interface{}{})
|
||||
}
|
||||
|
||||
func (d *Client) AccountBalance(account *string) (*AccountBalanceResponse, error) {
|
||||
response := new(AccountBalanceResponse)
|
||||
return response, d.call(response, "account_balance", map[string]interface{}{
|
||||
"account_id": account,
|
||||
})
|
||||
}
|
||||
|
||||
func (d *Client) AccountFund(fromAccount string, toAccount string, amount string, outputs uint64) (*AccountFundResponse, error) {
|
||||
response := new(AccountFundResponse)
|
||||
return response, d.call(response, "account_fund", map[string]interface{}{
|
||||
"from_account": fromAccount,
|
||||
"to_account": toAccount,
|
||||
"amount": amount,
|
||||
"outputs": outputs,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,8 +1,49 @@
|
|||
package jsonrpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func TestStatus(t *testing.T) {
|
||||
func TestClient_AccountList(t *testing.T) {
|
||||
d := NewClient("")
|
||||
got, err := d.AccountList()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Infof("%+v", *got)
|
||||
}
|
||||
|
||||
func TestClient_AccountBalance(t *testing.T) {
|
||||
d := NewClient("")
|
||||
got, err := d.AccountBalance(nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Infof("%s", *got)
|
||||
}
|
||||
|
||||
func TestClient_AccountFund(t *testing.T) {
|
||||
d := NewClient("")
|
||||
accounts, err := d.AccountList()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
account := (*accounts.LBCRegtest)[0].ID
|
||||
balanceString, err := d.AccountBalance(&account)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
balance, err := strconv.ParseFloat(string(*balanceString), 64)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
got, err := d.AccountFund(account, account, fmt.Sprintf("%f", balance-0.1), 40)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Infof("%+v", *got)
|
||||
}
|
||||
|
|
|
@ -374,3 +374,58 @@ type NumClaimsInChannelResponse map[string]struct {
|
|||
ClaimsInChannel uint64 `json:"claims_in_channel,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type Account struct {
|
||||
AddressGenerator struct {
|
||||
Change struct {
|
||||
Gap uint64 `json:"gap"`
|
||||
MaximumUsesPerAddress uint64 `json:"maximum_uses_per_address"`
|
||||
} `json:"change"`
|
||||
Name string `json:"name"`
|
||||
Receiving struct {
|
||||
Gap uint64 `json:"gap"`
|
||||
MaximumUsesPerAddress uint64 `json:"maximum_uses_per_address"`
|
||||
} `json:"receiving"`
|
||||
} `json:"address_generator"`
|
||||
Certificates uint64 `json:"certificates"`
|
||||
Coins float64 `json:"coins"`
|
||||
Encrypted bool `json:"encrypted"`
|
||||
ID string `json:"id"`
|
||||
IsDefaultAccount bool `json:"is_default_account"`
|
||||
Name string `json:"name"`
|
||||
PublicKey string `json:"public_key"`
|
||||
Satoshis uint64 `json:"satoshis"`
|
||||
}
|
||||
|
||||
type AccountListResponse struct {
|
||||
LBCMainnet *[]Account `json:"lbc_mainnet"`
|
||||
LBCTestnet *[]Account `json:"lbc_testnet"`
|
||||
LBCRegtest *[]Account `json:"lbc_regtest"`
|
||||
}
|
||||
type AccountBalanceResponse string
|
||||
|
||||
type AccountFundResponse struct {
|
||||
Height int64 `json:"height"`
|
||||
Hex string `json:"hex"`
|
||||
Inputs []struct {
|
||||
Address string `json:"address"`
|
||||
Amount string `json:"amount"`
|
||||
Confirmations int64 `json:"confirmations"`
|
||||
Height int64 `json:"height"`
|
||||
IsChange bool `json:"is_change"`
|
||||
IsMine bool `json:"is_mine"`
|
||||
Nout uint64 `json:"nout"`
|
||||
Txid string `json:"txid"`
|
||||
} `json:"inputs"`
|
||||
Outputs []struct {
|
||||
Address string `json:"address"`
|
||||
Amount string `json:"amount"`
|
||||
Confirmations int64 `json:"confirmations"`
|
||||
Height int64 `json:"height"`
|
||||
Nout uint64 `json:"nout"`
|
||||
Txid string `json:"txid"`
|
||||
} `json:"outputs"`
|
||||
TotalFee string `json:"total_fee"`
|
||||
TotalOutput string `json:"total_output"`
|
||||
Txid string `json:"txid"`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue