/
sdk_model.go
47 lines (39 loc) · 1.01 KB
/
sdk_model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2018 ProximaX Limited. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package sdk
import (
"encoding/binary"
"fmt"
"math/big"
)
type uint64DTO [2]uint32
func (dto uint64DTO) toBigInt() *big.Int {
if dto[0] == 0 && dto[1] == 0 {
return &big.Int{}
}
var int big.Int
b := make([]byte, len(dto)*4)
binary.BigEndian.PutUint32(b[:len(dto)*2], dto[1])
binary.BigEndian.PutUint32(b[len(dto)*2:], dto[0])
int.SetBytes(b)
return &int
}
func IntToHex(u uint32) string {
return fmt.Sprintf("%08x", u)
}
// analog JAVA Uint64.bigIntegerToHex
func BigIntegerToHex(id *big.Int) string {
u := FromBigInt(id)
return IntToHex(u[1]) + IntToHex(u[0])
}
func FromBigInt(int *big.Int) []uint32 {
var u64 uint64 = uint64(int.Int64())
l := uint32(u64 & 0xFFFFFFFF)
r := uint32(u64 >> 32)
return []uint32{l, r}
}
type AccountTransactionsOption struct {
PageSize int `url:"pageSize,omitempty"`
Id string `url:"id,omitempty"`
}