Categorygithub.com/affix6932/wallet-sdk
modulepackage
0.0.7
Repository: https://github.com/affix6932/wallet-sdk.git
Documentation: pkg.go.dev

# README

golang sdk example

document

java sdk

                   ,.-^^-._          ┌─┐                                                                                                  
                  |-.____.-|         ║"│                                                                                                  
                  |        |         └┬┘                                                                                                  
                  |        |         ┌┼┐                                                                                                  
                  |        |          │             ┌────────┐                     ┌──────┐           ┌────┐           ┌──────┐           
                  '-.____.-'         ┌┴┐            │Platform│                     │Wallet│           │Addr│           │Chains│           
                     DB             User            └────┬───┘                     └───┬──┘           └──┬─┘           └───┬──┘           
                      │               │                  │                             │                 │                 │              
          ╔═══════════╪══════════╤════╪══════════════════╪═════════════════════════════╪═════════════════╪═════╗           │              
          ║ GET&DISPLAY ADDRESS  │    │                  │                             │                 │     ║           │              
          ╟──────────────────────┘    │  𝟏 do deposit    │                             │                 │     ║           │              
          ║           │               │─────────────────>│                             │                 │     ║           │              
          ║           │               │                  │                             │                 │     ║           │              
          ║           │               │                  │                             │                 │     ║           │              
          ║           │               │   ╔═════════════╤╪═════════════════════════════╪═════════════╗   │     ║           │              
          ║           │               │   ║ FIRST TIME  ││                             │             ║   │     ║           │              
          ║           │               │   ╟─────────────┘│   𝟐 get deposit address     │             ║   │     ║           │              
          ║           │               │   ║              │────────────────────────────>│             ║   │     ║           │              
          ║           │               │   ║              │                             │             ║   │     ║           │              
          ║           │               │   ║              │         𝟑 address           │             ║   │     ║           │              
          ║           │               │   ║              │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │             ║   │     ║           │              
          ║           │               │   ╚══════════════╪═════════════════════════════╪═════════════╝   │     ║           │              
          ║           │               │                  │                             │                 │     ║           │              
          ║           │           𝟒 save||get            │                             │                 │     ║           │              
          ║           │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│                             │                 │     ║           │              
          ║           │               │                  │                             │                 │     ║           │              
          ║           │               │𝟓 display address │                             │                 │     ║           │              
          ║           │               │<─ ─ ─ ─ ─ ─ ─ ─ ─│                             │                 │     ║           │              
          ╚═══════════╪═══════════════╪══════════════════╪═════════════════════════════╪═════════════════╪═════╝           │              
                      │               │                  │                             │                 │                 │              
                      │               │                  │                             │                 │                 │              
                      │  ╔══════════╤═╪══════════════════╪═════════════════════════════╪═════════════════╪═════════════════╪═════════════╗
                      │  ║ DEPOSIT  │ │                  │                             │                 │                 │             ║
                      │  ╟──────────┘ │  𝟔 get address   │                             │                 │                 │             ║
                      │  ║            │─────────────────>│                             │                 │                 │             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │    𝟕 address     │                             │                 │                 │             ║
                      │  ║            │<─ ─ ─ ─ ─ ─ ─ ─ ─│                             │                 │                 │             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │                  │        𝟖 transfer           │                 │                 │             ║
                      │  ║            │─────────────────────────────────────────────────────────────────>│                 │             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │                  │                             │           𝟗 scan addr             │             ║
                      │  ║            │                  │                             │──────────────────────────────────>│             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │                  │                             │       𝟏𝟎 get deposit info         │             ║
                      │  ║            │                  │                             │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │                  │    𝟏𝟏 webhook callback      │                 │                 │             ║
                      │  ║            │                  │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │                 │                 │             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │                  │𝟏𝟐 check  transaction exists │                 │                 │             ║
                      │  ║            │                  │────────────────────────────>│                 │                 │             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │                  │                             │                 │                 │             ║
                      │  ║            │   ╔══════╤═══════╪═════════════════════════════╪═════════════╗   │                 │             ║
                      │  ║            │   ║ ALT  │  transaction exists                 │             ║   │                 │             ║
                      │  ║            │   ╟──────┘       │                             │             ║   │                 │             ║
                      │  ║            │   ║              │    𝟏𝟑 transaction info      │             ║   │                 │             ║
                      │  ║            │   ║              │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │             ║   │                 │             ║
                      │  ║            │   ╠══════════════╪═════════════════════════════╪═════════════╣   │                 │             ║
                      │  ║            │   ║ [not exists] │                             │             ║   │                 │             ║
                      │  ║            │   ║              │          𝟏𝟒 null            │             ║   │                 │             ║
                      │  ║            │   ║              │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │             ║   │                 │             ║
                      │  ║            │   ╚══════════════╪═════════════════════════════╪═════════════╝   │                 │             ║
                      │  ╚════════════╪══════════════════╪═════════════════════════════╪═════════════════╪═════════════════╪═════════════╝
                     DB             User            ┌────┴───┐                     ┌───┴──┐           ┌──┴─┐           ┌───┴──┐           
                   ,.-^^-._          ┌─┐            │Platform│                     │Wallet│           │Addr│           │Chains│           
                  |-.____.-|         ║"│            └────────┘                     └──────┘           └────┘           └──────┘           
                  |        |         └┬┘                                                                                                  
                  |        |         ┌┼┐                                                                                                  
                  |        |          │                                                                                                   
                  '-.____.-'         ┌┴┐

withdraw

                      ┌─┐                                                       ,.-^^-._                
                      ║"│                                                      |-.____.-|               
                      └┬┘                                                      |        |               
                      ┌┼┐                                                      |        |               
                       │             ┌────────┐                                |        |       ┌──────┐
                      ┌┴┐            │Platform│                                '-.____.-'       │Wallet│
                     User            └────┬───┘                                   DB            └───┬──┘
                       │   𝟏 withdraw     │                                        │                │   
                       │─────────────────>│                                        │                │   
                       │                  │                                        │                │   
                       │                  │𝟐 check balance && freeze/deduct amount │                │   
                       │                  │───────────────────────────────────────>│                │   
                       │                  │                                        │                │   
                       │                  │                                        │                │   
          ╔════════════╪╤═════════════════╪════════════════════════════════════════╪═══════════╗    │   
          ║ NOT ENOUGH  │                 │                                        │           ║    │   
          ╟─────────────┘                 │         𝟑 not enough, cancel           │           ║    │   
          ║            │                  │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│           ║    │   
          ║            │                  │                                        │           ║    │   
          ║            │𝟒 withdraw failed │                                        │           ║    │   
          ║            │<─ ─ ─ ─ ─ ─ ─ ─ ─│                                        │           ║    │   
          ╚════════════╪══════════════════╪════════════════════════════════════════╪═══════════╝    │   
                       │                  │                                        │                │   
                       │                  │                                        │                │   
                       │                  │                                        │                │   
                       │                  │                                        │                │   
                       │                  │                       𝟓 withdraw       │                │   
                       │                  │────────────────────────────────────────────────────────>│   
                       │                  │                                        │                │   
                       │                  │                          𝟔 ok          │                │   
                       │                  │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │   
                       │                  │                                        │                │   
                       │                  │               𝟕 callback withdraw detail                │   
                       │                  │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │   
                       │                  │                                        │                │   
                       │                  │                                        │                │   
                       │   ╔══════════════╤════════════════════════════════════════╪═══════════╗    │   
                       │   ║ DETAIL SUCC  │                                        │           ║    │   
                       │   ╟──────────────┘            𝟖 deduct amount             │           ║    │   
                       │   ║              │───────────────────────────────────────>│           ║    │   
                       │   ╠══════════════╪════════════════════════════════════════╪═══════════╣    │   
                       │   ║ [failed]     │                                        │           ║    │   
                       │   ║              │         𝟗 unfeeze/add amount           │           ║    │   
                       │   ║              │───────────────────────────────────────>│           ║    │   
                       │   ╚══════════════╪════════════════════════════════════════╪═══════════╝    │   
                     User            ┌────┴───┐                                   DB            ┌───┴──┐
                      ┌─┐            │Platform│                                 ,.-^^-._        │Wallet│
                      ║"│            └────────┘                                |-.____.-|       └──────┘
                      └┬┘                                                      |        |               
                      ┌┼┐                                                      |        |               
                       │                                                       |        |               
                      ┌┴┐                                                      '-.____.-'               

Common

W-Broker must in header.

Current support:

chaincoin
TONTON
TONUSDT
TRONUSDT
TRONTRX
BSCUSDT
ETHUSDT

resp always like:

// resp from gateway: {
"code": 0, // from gateway. 0: success, others: failed,
"data": "{\"msg\":\"\",\"code\":0,\"data\":{\"chain\":\"TON\",\"hash\":\"og6hrZpiFxjsKsfRAr+CIQd\",\"address\":\"EQAkhkg79yqAqbG67Ch5m8j\",\"tag\":\"2\",\"coin\":\"USDT\",\"amount\":\"0.222222\",\"blockNo\":\"\",\"txId\":\"da2c87300d993cc924b9085af5f5183a\"}}"
}

api resp body in data:
{
"msg": "",
"code": 0,
"data": {
"chain": "TON",
"hash": "og6hrZpiFxjsKsfRAr+CIQdZp",
"address": "EQAkhkg79yqAqbG67Ch5m8j",
"tag": "2",
"coin": "USDT",
"amount": "0.222222",
"blockNo": "",
"txId": "da2c87300d993cc924b9085af5f5183a"
}
}

Deposit.GetNewAddress

path: /v1/api/deposit/get_new_address

req:

nametypecommentrequire
requestIdstringuniq idy

resp:

nametypecomment
addressstringaddress
tagstringtag

Deposit.QueryDetail

path: /v1/api/deposit/query_detail

req:

nametypecommentrequire
requestIdstringuniq id. bussinessId, not transactionId on chainy
addressstringuser addressy
tagstringuser tagn

resp:

nametypecomment
chainstringchainName
hashstringhash from chain explorer
addressstringaddress
fromstringfrom
tagstringtag
coinstringcoin, USDT/TON/...
amountdecimal1.23456789
blockNostringblock info
requestIdstringuniqueID
exchangeRatedecimal(40,18)-
fiatAmountdecimal(40,18)-
symbolstring-
brokerstring-

Deposit.QueryDetailByTxId

path: /v1/api/deposit/query_detail_by_txid

req:

nametypecommentrequire
txIdstringtxid(hash) on chainy

resp:

nametypecomment
chainstringchainName
hashstringhash from chain explorer
addressstringaddress
fromstringfrom
tagstringtag
coinstringcoin, USDT/TON/...
amountdecimal1.23456789
blockNostringblock info
requestIdstringuniqueID
exchangeRatedecimal(40,18)-
fiatAmountdecimal(40,18)-
symbolstring-
brokerstring-

Deposit Callback Struct

nametypecomment
chainstringchainName
hashstringhash from chain explorer
addressstringaddress
fromstringfrom
tagstringtag
coinstringcoin, USDT/TON/...
amountdecimal(40,18)0.123456
exchangeRatedecimal(40,18)-
fiatAmountdecimal(40,18)-
symbolstring-
requestIdstringuniq ID-
brokerstring-

Withdraw.QueryDetail

path: /v1/api/withdraw/query_detail

req:

nametypecommentrequire
requestIdstringuniq idy

resp:

nametypecomment
requestIdstringuniq id
amountdecimal
coinstring
networkstring
tostring
tagstring
hashstring
stateint0: pending, 1: process, 2: succ 3:fail
gasdecimal
exchangeRatedecimal(40,18)-
fiatAmountdecimal(40,18)-
symbolstring-

Withdraw.DoWithdraw

path: /v1/api/withdraw

req:

nametypecommentrequire
requestIdstringuniq idy
amountdecimaly
coinstringy
networkstringy
tostringy
tagstringy

resp:

nametypecomment
codeint
msgint

Withdraw.DoWithdrawSymbol

path: /v1/api/withdraw_symbol

req:

nametypecommentrequire
requestIdstringuniq idy
fiatAmountdecimaly
symbolstringUSDT/EUR,USDT/BRLy
networkstringy
tostringy
tagstringy

resp:

nametypecomment
codeint
msgint

Withdraw Callback Struct

nametypecomment
networkstring-
coinstring-
fromstring-
tostring-
amountdecimal(40,18)-
requestIdstringuniq id-
hashstringhash on chain-
gasdecimal(40,18)-
tagstring-
exchangeRatedecimal(40,18)-
fiatAmountdecimal(40,18)-
symbolstring-

Exchange Rate

path: /v1/api/exchange_rate

req:

nametypecommentrequire
symbolstringUSDT/USD,USDT/EUR,USDT/BRL ...y

resp:

nametypecomment
pricedecimal(40, 18)USDT to USD/EUR/BRL price0.9999
updatedAtinttimestamp(10)1731470665

Get Deposit Min Limit

path: /v1/api/deposit/get_deposit_min_limit

req:

nametypecommentrequire
chainstringTRON/TON ...y
coinstringTRX/TON/USDT ...y

resp:

nametypecomment
amountdecimal(40, 18)deposit will callback when greater than min amount0.9999

Set Deposit Min Limit

path: /v1/api/deposit/set_deposit_min_limit

req:

nametypecommentrequire
chainstringTRON/TON ...y
coinstringTRX/TON/USDT ...y
amountdecimal(40, 18)y

resp: Returns null by default, if it fails, code will not be 0. If the setting is successful, it will take effect in one minute.

sdk example

    // prod
ops := []sdk.Option{
sdk.WithSecretPath("../test/public_key.pem"),
sdk.WithCertPath(("../test/server/ca.crt"), ("../test/server/test_client.crt"), ("../test/server/test_client.key")),
sdk.WithCustomer("a"),
}
w, err := sdk.Init(ops...)
if err != nil {
t.Fatal(err)
}

d := NewDeposit(w, URL)
resp, err := d.GetNewAddress(context.Background(), &GetNewAddrReq{
Network:   "TON",
RequestId: "12345",
})

    // test
ops := []sdk.Option{
sdk.WithCustomer("a"),
sdk.WithTest(true),
}
w, err := sdk.Init(ops...)
if err != nil {
t.Fatal(err)
}

d := NewDeposit(URL)
resp, err := d.GetNewAddress(context.Background(), &GetNewAddrReq{
Network:   "TON",
RequestId: "12345",
})
if err != nil {
t.Fatal(err)
}

java sdk

java sdk

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author