diff --git a/wallet/components/rpc.go b/wallet/components/rpc.go index 3760a7a..d13b35d 100644 --- a/wallet/components/rpc.go +++ b/wallet/components/rpc.go @@ -39,7 +39,7 @@ func xdagjRpc(method string, params string) (string, error) { } request.Header.Set("Content-Type", "application/json") client := &http.Client{ - Timeout: 15 * time.Second, + Timeout: 20 * time.Second, } response, err := client.Do(request) if err != nil { @@ -103,25 +103,17 @@ func transactionBlock(from, to, remark string, value float64, key *secp256k1.Pri } var inAddress string var err error - isFromOld := len(from) == common.XDAG_ADDRESS_SIZE + + inAddress, err = checkBase58Address(from) + isFromOld := err != nil if isFromOld { // old xdag address - if !ValidateXdagAddress(from) { - xlog.Error("transaction send address length error") - return "" - } hash, err := xdagoUtils.Address2Hash(from) if err != nil { - xlog.Error(err) + xlog.Error("transaction send address length error") return "" } inAddress = hex.EncodeToString(hash[:24]) - } else { // new base58 address - inAddress, err = checkBase58Address(from) - if err != nil { - xlog.Error(err) - return "" - } } outAddress, err := checkBase58Address(to) diff --git a/wallet/wallet-config.json b/wallet/wallet-config.json index 283e6a9..6b331f9 100644 --- a/wallet/wallet-config.json +++ b/wallet/wallet-config.json @@ -1,21 +1,21 @@ -{ - "wallet_option": { - "rpc_enabled": false, - "rpc_port": null, - "specified_pool_address": null, - "is_test_net": false, - "disable_mining": true, - "pool_address": "https://mainnet-rpc.xdagj.org", - "testnet_api_url": "" - }, - "version": "0.6.4", - "culture_info": "en-US", - "addresses": [], - "query": { - "amount_from": "", - "amount_to": "", - "timestamp": "", - "remark": "", - "direction": "" - } +{ + "wallet_option": { + "rpc_enabled": false, + "rpc_port": null, + "specified_pool_address": null, + "is_test_net": false, + "disable_mining": true, + "pool_address": "https://mainnet-rpc.xdagj.org", + "testnet_api_url": "" + }, + "version": "0.6.5", + "culture_info": "en-US", + "addresses": [], + "query": { + "amount_from": "", + "amount_to": "", + "timestamp": "", + "remark": "", + "direction": "" + } } \ No newline at end of file diff --git a/wallet/xdago/utils/block_test.go b/wallet/xdago/utils/block_test.go new file mode 100644 index 0000000..bd4711a --- /dev/null +++ b/wallet/xdago/utils/block_test.go @@ -0,0 +1,36 @@ +package utils + +import ( + "encoding/hex" + "errors" + "fmt" + "goXdagWallet/xdago/base58" + "goXdagWallet/xdago/common" + "testing" +) + +func TestAddress(t *testing.T) { + bs := "cd999e172c0d3e36850b6a3d5202638e4735bfc83be0ca0b" + b, _ := hex.DecodeString(bs) + var h common.Hash + copy(h[:], b[:]) + a := Hash2Address(h) + fmt.Println(a) + + h2, err := Address2Hash(a) + if err != nil { + panic(err) + } + + fmt.Println(h2) + + addrBytes, _, err := base58.ChkDec(a) + if err != nil { + panic(err) + } + if len(addrBytes) != 24 { + panic(errors.New("transaction receive address length error")) + } + fmt.Println(addrBytes) + +}