lbtcTransaction

package
v1.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeEmpty    = 0
	TypeP2PKH    = 1
	TypeP2WPKH   = 2
	TypeBech32   = 3
	TypeMultiSig = 4
)
View Source
const (
	DefaultTxVersion = uint32(65282)
	//DefaultTxVersion     = uint32(1)
	DefaultHashType      = uint32(1)
	MaxScriptElementSize = 520
)
View Source
const (
	SequenceFinal        = uint32(0xFFFFFFFF)
	SequenceMaxBip125RBF = uint32(0xFFFFFFFD)
)
View Source
const (
	SegWitSymbol  = byte(0)
	SegWitVersion = byte(1)
	SigHashAll    = byte(1) //byte(0x41)
)
View Source
const (
	OpCodeHash160     = byte(0xA9)
	OpCodeEqual       = byte(0x87)
	OpCodeEqualVerify = byte(0x88)
	OpCodeCheckSig    = byte(0xAC)
	OpCodeDup         = byte(0x76)
	OpCode_1          = byte(0x51)
	OpCheckMultiSig   = byte(0xAE)
	OpPushData1       = byte(0x4C)
	OpPushData2       = byte(0x4D)
	OpPushData3       = byte(0x4E)
	OpReturn          = byte(0x6A)
)
View Source
const (
	SimpleSend             = 0
	SendAll                = 4
	DExAccept              = 22
	MetaDExCancelEcosystem = 28
	CloseCrowdsale         = 53
	Grant                  = 55
	Revoke                 = 56
	ChangeIssuer           = 70
	EnableFreezing         = 71
	DisableFreezing        = 72
	FreezeTokens           = 185
	UnfreezeTokens         = 186
)

Omni transaction type

View Source
const (
	MainTetherUS_01 = uint32(31)
	MainTetherUS_02 = uint32(192)
	MainTetherUS_03 = uint32(330)
	MainTetherUS_04 = uint32(341)
	MainTetherUS_05 = uint32(396)
	MainTetherUS_06 = uint32(397)
	MainTetherUS_07 = uint32(398)
	MainTetherUS_08 = uint32(399)
	MainTetherUS_09 = uint32(404)

	TestTetherUS_01 = uint32(2147484026)
	TestTetherUS_02 = uint32(2147484061)
	TestTetherUS_03 = uint32(2147484062)

	DefaultTetherUSID = TestTetherUS_01
)

propertyID for USDT

View Source
const (
	EcoSystemMain = byte(1)
	EcoSystemTest = byte(2)

	DefaultEcoSystem = EcoSystemTest
)

ecosystem defination for send all payload

Variables

View Source
var (
	BTCMainnetAddressPrefix = AddressPrefix{[]byte{0x00}, []byte{0x05}, nil, "bc"}
	BTCTestnetAddressPrefix = AddressPrefix{[]byte{0x6F}, []byte{0xC4}, nil, "tb"}
	BCHMainnetAddressPrefix = AddressPrefix{[]byte{0x00}, []byte{0x05}, nil, "bc"}
	BCHTestnetAddressPrefix = AddressPrefix{[]byte{0x6F}, []byte{0xC4}, nil, "tb"}
	LTCMainnetAddressPrefix = AddressPrefix{[]byte{0x30}, []byte{0x05}, []byte{0x32}, "ltc"}
	LTCTestnetAddressPrefix = AddressPrefix{[]byte{0x6F}, []byte{0xC4}, []byte{0x3A}, "tltc"}
	ZECMainnetAddressPrefix = AddressPrefix{[]byte{0x1C, 0xB8}, []byte{0x1C, 0xBD}, nil, ""}
	ZECTestnetAddressPrefix = AddressPrefix{[]byte{0x1D, 0x25}, []byte{0x1C, 0xBA}, nil, ""}
)
View Source
var (
	OmniPrefix     = [4]byte{0x6F, 0x6D, 0x6E, 0x69}
	CurveOrder     = []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41}
	HalfCurveOrder = []byte{0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0}
)
View Source
var (
	BitcoinAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
)

Alphabet: copy from https://en.wikipedia.org/wiki/Base58

View Source
var (
	ErrorInvalidBase58String = errors.New("invalid base58 string")
)

Errors

Functions

func CreateEmptyOmniRawTransaction

func CreateEmptyOmniRawTransaction(vins []Vin, vouts []Vout, omniDetail OmniStruct, lockTime uint32, replaceable bool, addressPrefix AddressPrefix) (string, error)

func CreateEmptyRawTransaction

func CreateEmptyRawTransaction(vins []Vin, vouts []Vout, lockTime uint32, replaceable bool, addressPrefix AddressPrefix) (string, error)

func CreateMultiSig

func CreateMultiSig(required byte, pubkeys [][]byte, SegwitON bool, addressPrefix AddressPrefix) (string, string, error)

func Decode

func Decode(input string, alphabet *Alphabet) ([]byte, error)

Decode docode with custom alphabet

func DecodeCheck

func DecodeCheck(address string) ([]byte, []byte, error)

return prefix + hash + error

func Encode

func Encode(input []byte, alphabet *Alphabet) string

Encode encode with custom alphabet

func EncodeCheck

func EncodeCheck(prefix []byte, hash []byte) string

func InsertSignatureIntoEmptyTransaction

func InsertSignatureIntoEmptyTransaction(txHex string, txHashes []TxHash, unlockData []TxUnlock, SegwitON bool) (string, error)

func VerifyRawTransaction

func VerifyRawTransaction(txHex string, unlockData []TxUnlock, SegwitON bool, addressPrefix AddressPrefix) bool

Types

type AddressPrefix

type AddressPrefix struct {
	P2PKHPrefix  []byte
	P2WPKHPrefix []byte
	P2SHPrefix   []byte
	Bech32Prefix string
}

type Alphabet

type Alphabet struct {
	// contains filtered or unexported fields
}

Alphabet The base58 alphabet object.

func NewAlphabet

func NewAlphabet(alphabet string) *Alphabet

NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.

func (Alphabet) String

func (alphabet Alphabet) String() string

Alphabet's string representation

type MultiTx

type MultiTx struct {
	Pubkey  string
	SigType byte
	SigPub  SignaturePubkey
}

type NormalTx

type NormalTx struct {
	Address string
	SigType byte
	SigPub  SignaturePubkey
}

type OmniStruct

type OmniStruct struct {
	TxType     int
	PropertyId uint32
	Amount     uint64
	Ecosystem  byte
	Memo       string
	Address    string
}

type SignaturePubkey

type SignaturePubkey struct {
	Signature []byte
	Pubkey    []byte
}

func SignRawTransactionHash

func SignRawTransactionHash(txHash string, prikey []byte) (*SignaturePubkey, error)

type Transaction

type Transaction struct {
	Version  []byte
	Vins     []TxIn
	Vouts    []TxOut
	LockTime []byte
	Witness  bool
}

func DecodeRawTransaction

func DecodeRawTransaction(txBytes []byte, SegwitON bool) (*Transaction, error)

type TxHash

type TxHash struct {
	Hash      string
	NRequired byte
	Normal    *NormalTx
	Multi     []MultiTx
}

func CreateRawTransactionHashForSig

func CreateRawTransactionHashForSig(txHex string, unlockData []TxUnlock, SegwitON bool, addressPrefix AddressPrefix) ([]TxHash, error)

func (TxHash) GetMultiTxPubkeys

func (tx TxHash) GetMultiTxPubkeys() []string

func (TxHash) GetNormalTxAddress

func (tx TxHash) GetNormalTxAddress() string

func (TxHash) GetTxHashHex

func (tx TxHash) GetTxHashHex() string

func (TxHash) IsMultisig

func (tx TxHash) IsMultisig() bool

type TxIn

type TxIn struct {
	TxID []byte
	Vout []byte
	// contains filtered or unexported fields
}

func (TxIn) GetTxID

func (in TxIn) GetTxID() string

func (TxIn) GetUTXOType

func (in TxIn) GetUTXOType() int

func (TxIn) GetVout

func (in TxIn) GetVout() uint32

type TxOut

type TxOut struct {
	// contains filtered or unexported fields
}

type TxUnlock

type TxUnlock struct {
	//PrivateKey   []byte
	LockScript   string
	RedeemScript string
	Amount       uint64
	//	Address      string
	SigType byte
}

type Vin

type Vin struct {
	TxID string
	Vout uint32
}

type Vout

type Vout struct {
	Address string
	Amount  uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL