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"` +}