Skip to content

Commit

Permalink
Merge pull request #72 from XDagger/develop
Browse files Browse the repository at this point in the history
change rpc timeout seconds
  • Loading branch information
swordlet authored Apr 19, 2023
2 parents 2b70958 + b2ca4a3 commit b36ed95
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 33 deletions.
18 changes: 5 additions & 13 deletions wallet/components/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
40 changes: 20 additions & 20 deletions wallet/wallet-config.json
Original file line number Diff line number Diff line change
@@ -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": ""
}
}
36 changes: 36 additions & 0 deletions wallet/xdago/utils/block_test.go
Original file line number Diff line number Diff line change
@@ -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)

}

0 comments on commit b36ed95

Please sign in to comment.