From 02d9aa7d38a42d532f0467ee7dbddd536ccc0ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BF=97=E6=B3=89?= Date: Thu, 25 Apr 2019 20:14:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B1=87=E6=80=BB=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openwsdk/model_test.go | 51 ++++++++++++++++++++++++++++++++++++++++++ openwsdk/models.go | 20 +++++++++++++---- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/openwsdk/model_test.go b/openwsdk/model_test.go index 22347fb..c76c16f 100644 --- a/openwsdk/model_test.go +++ b/openwsdk/model_test.go @@ -1,6 +1,7 @@ package openwsdk import ( + "encoding/json" "github.com/blocktree/openwallet/common/file" "github.com/blocktree/openwallet/hdkeystore" "github.com/blocktree/openwallet/log" @@ -49,3 +50,53 @@ func TestWallet_CreateAccount(t *testing.T) { } log.Infof("account:%+v", account) } + +func TestSummaryTaskUnmarshal(t *testing.T) { + plain := ` + +{ + "wallets": [{ + "walletID": "WN84dVZXpgVixsvXnU8jkFWD1qWHp15LpA", + "password": "12345678", + "accounts": [ + { + "accountID": "A3Mxhqm65kTgS2ybHLenNrZzZNtLGVobDFYdpc1ge4eK", + "threshold": "1000", + "minTransfer": "1000", + "retainedBalance": "0", + "confirms": 1, + "feeRate": "0.0001", + "onlyContracts": false, + "contracts": { + "all": { + "threshold": "1000", + "minTransfer": "1000", + "retainedBalance": "0" + }, + "3qoe2ll2=": { + "threshold": "1000", + "minTransfer": "1000", + "retainedBalance": "0" + } + }, + "feesSupportAccount": { + "accountID": "12323", + "lowBalanceWarning": "0.1" + } + }, + { + "accountID": "3i26MQmtuWVVnw8GnRCVopG3pi8MaYU6RqWVV2E1hwJx", + "feeRate": "0.001" + } + ] + }] +} + +` + var summaryTask SummaryTask + err := json.Unmarshal([]byte(plain), &summaryTask) + if err != nil { + log.Error("json.Unmarshal error:", err) + return + } +} \ No newline at end of file diff --git a/openwsdk/models.go b/openwsdk/models.go index edec035..54977be 100644 --- a/openwsdk/models.go +++ b/openwsdk/models.go @@ -245,10 +245,16 @@ func NewSummaryTask(result gjson.Result) *SummaryTask { } type SummaryAccountTask struct { - AccountID string `json:"accountID"` - Contracts []string `json:"contracts"` - FeeRate string `json:"feeRate"` - SummarySetting *SummarySetting `json:"summarySetting"` + AccountID string `json:"accountID"` + Contracts map[string]*SummaryContractTask `json:"contracts"` + FeeRate string `json:"feeRate"` + OnlyContracts bool `json:"onlyContracts"` + FeesSupportAccount *FeesSupportAccount `json:"feesSupportAccount"` + *SummarySetting +} + +type SummaryContractTask struct { + *SummarySetting } type SummaryWalletTask struct { @@ -358,3 +364,9 @@ func NewTokenBalance(result gjson.Result) *TokenBalance { } return &b } + +// FeesSupportAccount 主币余额不足时,可选择一个账户提供手续费 +type FeesSupportAccount struct { + AccountID string `json:"accountID"` + LowBalanceWarning string `json:"lowBalanceWarning"` +}