address

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 15 Imported by: 14

Documentation

Index

Constants

View Source
const (
	Mainnet Mode = "ckb"
	Testnet Mode = "ckt"

	Short       Type = "Short"
	FullBech32  Type = "FullBech32"
	FullBech32m Type = "FullBech32m"

	TYPE_FULL_WITH_BECH32M    = "00"
	ShortFormat               = "01"
	CodeHashIndexSingleSig    = "00"
	CodeHashIndexMultisigSig  = "01"
	CodeHashIndexAnyoneCanPay = "02"
)
View Source
const (
	MAINNET_ACP_CODE_HASH    = "0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354"
	TESTNET_ACP_CODE_HASH    = "0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356"
	MAINNET_CHEQUE_CODE_HASH = "0xe4d4ecc6e5f9a059bf2f7a82cca292083aebc0c421566a52484fe2ec51a9fb0c"
	TESTNET_CHEQUE_CODE_HASH = "0x60d5f39efce409c587cb9ea359cefdead650ca128f0bd9cb3855348f98c70d5b"
)

Variables

This section is empty.

Functions

func ConvertPublicToAddress added in v0.101.1

func ConvertPublicToAddress(mode Mode, publicKey string) (string, error)

func ConvertScriptToAddress added in v0.101.1

func ConvertScriptToAddress(mode Mode, script *types.Script) (string, error)

func ConvertScriptToBech32mFullAddress added in v0.101.1

func ConvertScriptToBech32mFullAddress(mode Mode, script *types.Script) (string, error)

func ConvertScriptToFullAddress deprecated added in v0.101.1

func ConvertScriptToFullAddress(mode Mode, script *types.Script) (string, error)

Deprecated: Old full address format is deprecated because a flaw has been found in its encoding method bech32, which could enable attackers to generate valid but unexpected addresses. For more please check https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0021-ckb-address-format/0021-ckb-address-format.md

func ConvertScriptToShortAddress deprecated added in v0.101.1

func ConvertScriptToShortAddress(mode Mode, script *types.Script) (string, error)

Deprecated: Short address format deprecated because it is limited (only support secp256k1_blake160, secp256k1_multisig, anyone_can_pay) and a flaw has been found in its encoding method bech32, which could enable attackers to generate valid but unexpected addresses. For more please check https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0021-ckb-address-format/0021-ckb-address-format.md

func ConvertToBech32FullAddress deprecated added in v0.101.2

func ConvertToBech32FullAddress(address string) (string, error)

Deprecated: Old full address format is deprecated because a flaw has been found in its encoding method bech32, which could enable attackers to generate valid but unexpected addresses. For more please check https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0021-ckb-address-format/0021-ckb-address-format.md

func ConvertToBech32mFullAddress added in v0.101.2

func ConvertToBech32mFullAddress(address string) (string, error)

func ConvertToShortAddress deprecated added in v0.101.2

func ConvertToShortAddress(address string) (string, error)

Deprecated: Short address format deprecated because it is limited (only support secp256k1_blake160, secp256k1_multisig, anyone_can_pay) and a flaw has been found in its encoding method bech32, which could enable attackers to generate valid but unexpected addresses. For more please check https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0021-ckb-address-format/0021-ckb-address-format.md

func GenerateAcpAddress added in v0.43.1

func GenerateAcpAddress(secp256k1Address string) (string, error)

func GenerateChequeAddress added in v0.43.1

func GenerateChequeAddress(senderAddress, receiverAddress string) (string, error)

func GenerateSecp256k1MultisigScript

func GenerateSecp256k1MultisigScript(requireN, threshold int, publicKeysOrHashes [][]byte) (*types.Script, []byte, error)

GenerateSecp256k1MultisigScript generate scep256k1 multisig script. It can accept public key (in compressed format, 33 bytes each) array or public key hash (20 bytes) array, and return error if giving none of them.

Types

type AddressGenerateResult added in v0.43.1

type AddressGenerateResult struct {
	Address    string
	LockArgs   string
	PrivateKey string
}

func GenerateAddress added in v0.101.1

func GenerateAddress(mode Mode) (*AddressGenerateResult, error)

func GenerateBech32mFullAddress added in v0.101.1

func GenerateBech32mFullAddress(mode Mode) (*AddressGenerateResult, error)

func GenerateFullAddress deprecated added in v0.101.1

func GenerateFullAddress(mode Mode) (*AddressGenerateResult, error)

Deprecated: Old full address format is deprecated because a flaw has been found in its encoding method bech32, which could enable attackers to generate valid but unexpected addresses. For more please check https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0021-ckb-address-format/0021-ckb-address-format.md

func GenerateShortAddress deprecated added in v0.43.1

func GenerateShortAddress(mode Mode) (*AddressGenerateResult, error)

Deprecated: Short address format deprecated because it is limited (only support secp256k1_blake160, secp256k1_multisig, anyone_can_pay) and a flaw has been found in its encoding method bech32, which could enable attackers to generate valid but unexpected addresses. For more please check https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0021-ckb-address-format/0021-ckb-address-format.md

type Mode

type Mode string

type ParsedAddress

type ParsedAddress struct {
	Mode   Mode
	Type   Type
	Script *types.Script
}

func Parse

func Parse(address string) (*ParsedAddress, error)

func ValidateChequeAddress added in v0.3.0

func ValidateChequeAddress(addr string, systemScripts *utils.SystemScripts) (*ParsedAddress, error)

type Type

type Type string

Jump to

Keyboard shortcuts

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