Smartcontract (#39)
* deleted transfer_output added asset type and transaction result to core * removed writing 0x00 when buffer length is 0 * Refactored emit into VM package + moved tx to own package. * implemented transaction along with claimTransaction. * refactored naming of transaction + added decode address for uint160 types * removed unnecessary folder and files. * transaction/smartcontract logic * bumped version 0.24.0
This commit is contained in:
parent
42195b1af4
commit
1a1a19da7d
36 changed files with 1066 additions and 170 deletions
|
@ -3,6 +3,8 @@ package util
|
|||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/CityOfZion/neo-go/pkg/crypto"
|
||||
)
|
||||
|
||||
const uint160Size = 20
|
||||
|
@ -22,6 +24,16 @@ func Uint160DecodeString(s string) (u Uint160, err error) {
|
|||
return Uint160DecodeBytes(b)
|
||||
}
|
||||
|
||||
// Uint160DecodeAddress attempts to decode the given NEO address string
|
||||
// into an Uint160.
|
||||
func Uint160DecodeAddress(s string) (u Uint160, err error) {
|
||||
b, err := crypto.Base58CheckDecode(s)
|
||||
if err != nil {
|
||||
return u, err
|
||||
}
|
||||
return Uint160DecodeBytes(b[1:21])
|
||||
}
|
||||
|
||||
// Uint160DecodeBytes attempts to decode the given bytes into an Uint160.
|
||||
func Uint160DecodeBytes(b []byte) (u Uint160, err error) {
|
||||
if len(b) != uint160Size {
|
||||
|
@ -42,6 +54,13 @@ func (u Uint160) Bytes() []byte {
|
|||
return b
|
||||
}
|
||||
|
||||
// Address returns the NEO address representation of u.
|
||||
func (u Uint160) Address() string {
|
||||
// Dont forget to prepend the Address version 0x17 (23) A
|
||||
b := append([]byte{0x17}, u.Bytes()...)
|
||||
return crypto.Base58CheckEncode(b)
|
||||
}
|
||||
|
||||
// String implements the stringer interface.
|
||||
func (u Uint160) String() string {
|
||||
return hex.EncodeToString(u.Bytes())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue