|
@@ -31,7 +31,7 @@ type DcrCash struct {
|
|
|
const (
|
|
|
NameCoin = "DCR"
|
|
|
SendToError = "-32603"
|
|
|
- DefaultMaxsumamout = 20.0
|
|
|
+ DefaultMaxsumamout = 100.0
|
|
|
DEFAULTACCOUNT = "default"
|
|
|
)
|
|
|
|
|
@@ -196,29 +196,36 @@ func (m *DcrCash) SumcoinBalance(parm interface{}) ([]byte, error) {
|
|
|
Minsumamount = WalleTxfee
|
|
|
}
|
|
|
|
|
|
- accountsofValues, err := CoinApi.ListAccounts()
|
|
|
- if err != nil {
|
|
|
- LOG("ERROR", "List accounts error:%v", err.Error())
|
|
|
- return nil, err
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- AccValues := map[string]float64{}
|
|
|
- if err = json.Unmarshal(accountsofValues, &AccValues); err != nil {
|
|
|
- LOG("ERROR", "Unmarshal error:%v", err.Error())
|
|
|
- return nil, err
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
var Totalbalance float64
|
|
|
- fmt.Println("SumcoinBalance >>>>:", len(AccValues), "Sumamount:", Sumamount, "Minsumamount", Minsumamount)
|
|
|
+ fmt.Println("SumcoinBalance >>>>:", len(m_AccValues), "Sumamount:", Sumamount, "Minsumamount", Minsumamount)
|
|
|
transactionsids := make([]string, 0)
|
|
|
- for account, value := range AccValues {
|
|
|
+ for account, value := range m_AccValues {
|
|
|
if (value > Minsumamount) && account != DEFAULTACCOUNT {
|
|
|
fmt.Println("SumcoinBalance account:", account, "value:", value)
|
|
|
amount := value - WalleTxfee
|
|
|
transactionid, err := CoinApi.WalletSendFrom(account, DEFAULTACCOUNT, amount, 1, "", "")
|
|
|
if err != nil {
|
|
|
LOG("ERROR", " Send coin error:%v", err.Error())
|
|
|
+ for {
|
|
|
+ amount -= 0.001
|
|
|
+ transactionid, err = CoinApi.WalletSendFrom(account, DEFAULTACCOUNT, amount, 1, "", "")
|
|
|
+ if transactionid != "" || amount <= 0.001 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- continue
|
|
|
+
|
|
|
}
|
|
|
transactionsids = append(transactionsids, transactionid)
|
|
|
Totalbalance += amount
|
|
@@ -230,6 +237,7 @@ func (m *DcrCash) SumcoinBalance(parm interface{}) ([]byte, error) {
|
|
|
}
|
|
|
if len(transactionsids) != 0 {
|
|
|
var jbuf []byte
|
|
|
+ var err error
|
|
|
resp := make(map[string]interface{})
|
|
|
resp["transcationids"] = transactionsids
|
|
|
resp["errcode"] = 0
|
|
@@ -572,7 +580,7 @@ func Cachelistaccount() {
|
|
|
func AsyncRoutine() {
|
|
|
CacheGetbalanceTicker := time.NewTicker(120 * time.Second)
|
|
|
CachelistaccountTicker := time.NewTicker(90 * time.Second)
|
|
|
- CachelistunspentTicker := time.NewTicker(120 * time.Second)
|
|
|
+ CachelistunspentTicker := time.NewTicker(180 * time.Second)
|
|
|
for {
|
|
|
select {
|
|
|
case _ = <-CacheGetbalanceTicker.C:
|