blackhat

package
v0.0.0-...-77992ff Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Net Magics
	MainnetMagic wire.BitcoinNet = 0xd9fdc2fa
	TestnetMagic wire.BitcoinNet = 0xc0d890c5

	// Opcodes
	OP_IF                   = 0x63
	OP_ELSE                 = 0x67
	OP_ENDIF                = 0x68
	OP_DUP                  = 0x76
	OP_ROT                  = 0x7b
	OP_EQUALVERIFY          = 0x88
	OP_HASH160              = 0xa9
	OP_CHECKSIG             = 0xac
	OP_ZEROCOINMINT         = 0xc1
	OP_ZEROCOINSPEND        = 0xc2
	OP_CHECKCOLDSTAKEVERIFY = 0xd1

	// Labels
	ZCMINT_LABEL  = "Zerocoin Mint"
	ZCSPEND_LABEL = "Zerocoin Spend"
	CBASE_LABEL   = "CoinBase TX"
	CSTAKE_LABEL  = "CoinStake TX"

	// Dummy Internal Addresses
	CBASE_ADDR_INT  = 0xf7
	CSTAKE_ADDR_INT = 0xf8

	// Staking Addresses
	STAKING_ADDR_MAIN = 63
	STAKING_ADDR_TEST = 73
)

Variables

View Source
var (
	MainNetParams chaincfg.Params
	TestNetParams chaincfg.Params
)

Functions

func GetChainParams

func GetChainParams(chain string) *chaincfg.Params

GetChainParams contains network parameters for the main BlackHat network

func NewBlackHatRPC

func NewBlackHatRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)

NewBlackHatRPC returns new BlackHatRPC instance.

func Uint16

func Uint16(r io.Reader, byteOrder binary.ByteOrder) (uint16, error)

Uint16 reads two bytes from the provided reader, converts it to a number using the provided byte order, and returns the resulting uint16.

func Uint32

func Uint32(r io.Reader, byteOrder binary.ByteOrder) (uint32, error)

Uint32 reads four bytes from the provided reader, converts it to a number using the provided byte order, and returns the resulting uint32.

func Uint64

func Uint64(r io.Reader, byteOrder binary.ByteOrder) (uint64, error)

Uint64 reads eight bytes from the provided reader, converts it to a number using the provided byte order, and returns the resulting uint64.

func Uint8

func Uint8(r io.Reader) (uint8, error)

Uint8 reads one byte from the provided reader and returns the resulting uint8.

Types

type BlackHatParser

type BlackHatParser struct {
	*btc.BitcoinParser

	BitcoinOutputScriptToAddressesFunc btc.OutputScriptToAddressesFunc
	// contains filtered or unexported fields
}

BlackHatParser handle

func NewBlackHatParser

func NewBlackHatParser(params *chaincfg.Params, c *btc.Configuration) *BlackHatParser

NewBlackHatParser returns new BlackHatParser instance

func (*BlackHatParser) GetAddrDescForUnknownInput

func (p *BlackHatParser) GetAddrDescForUnknownInput(tx *bchain.Tx, input int) bchain.AddressDescriptor

func (*BlackHatParser) GetValueSatForUnknownInput

func (p *BlackHatParser) GetValueSatForUnknownInput(tx *bchain.Tx, input int) *big.Int

func (*BlackHatParser) GetValueSatFromZerocoinSpend

func (p *BlackHatParser) GetValueSatFromZerocoinSpend(signatureScript []byte) (*big.Int, error)

Decodes the amount from the zerocoin spend script

func (*BlackHatParser) IsAddrDescIndexable

func (p *BlackHatParser) IsAddrDescIndexable(addrDesc bchain.AddressDescriptor) bool

IsAddrDescIndexable returns true if AddressDescriptor should be added to index empty or OP_RETURN scripts are not indexed. also are not indexed: zerocoin mints/spends coinbase txes and coinstake markers

func (*BlackHatParser) P2CSScriptToAddress

func (p *BlackHatParser) P2CSScriptToAddress(script []byte) ([]string, bool, error)

Returns P2CS owner/staker addresses

func (*BlackHatParser) PackTx

func (p *BlackHatParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error)

PackTx packs transaction to byte array using protobuf

func (*BlackHatParser) ParseTx

func (p *BlackHatParser) ParseTx(b []byte) (*bchain.Tx, error)

ParseTx parses byte array containing transaction and returns Tx struct

func (*BlackHatParser) ParseTxFromJson

func (p *BlackHatParser) ParseTxFromJson(msg json.RawMessage) (*bchain.Tx, error)

ParseTxFromJson parses JSON message containing transaction and returns Tx struct

func (*BlackHatParser) TxFromMsgTx

func (p *BlackHatParser) TxFromMsgTx(t *wire.MsgTx, parseAddresses bool) bchain.Tx

Parses tx and adds handling for OP_ZEROCOINSPEND inputs

func (*BlackHatParser) UnpackTx

func (p *BlackHatParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error)

UnpackTx unpacks transaction from protobuf byte array

type BlackHatRPC

type BlackHatRPC struct {
	*btc.BitcoinRPC
	BitcoinGetChainInfo func() (*bchain.ChainInfo, error)
}

BlackHatRPC is an interface to JSON-RPC bitcoind service.

func (*BlackHatRPC) Findzcserial

func (b *BlackHatRPC) Findzcserial(serialHex string) (string, error)

func (*BlackHatRPC) GetBlock

func (z *BlackHatRPC) GetBlock(hash string, height uint32) (*bchain.Block, error)

GetBlock returns block with given hash.

func (*BlackHatRPC) GetChainInfo

func (b *BlackHatRPC) GetChainInfo() (*bchain.ChainInfo, error)

GetChainInfo returns information about the connected backend BlackHat adds Money Supply to btc implementation

func (*BlackHatRPC) GetNextSuperBlock

func (b *BlackHatRPC) GetNextSuperBlock(nHeight int) int

GetNextSuperBlock returns the next superblock height after nHeight

func (*BlackHatRPC) Initialize

func (b *BlackHatRPC) Initialize() error

Initialize initializes BlackHatRPC instance.

type CmdFindSerial

type CmdFindSerial struct {
	Method string   `json:"method"`
	Params []string `json:"params"`
}

findserial

type CmdGetInfo

type CmdGetInfo struct {
	Method string `json:"method"`
}

type CmdGetMasternodeCount

type CmdGetMasternodeCount struct {
	Method string `json:"method"`
}

type ResFindSerial

type ResFindSerial struct {
	Error  *bchain.RPCError `json:"error"`
	Result struct {
		Success bool   `json:"success"`
		Txid    string `json:"txid"`
	} `json:"result"`
}

type ResGetInfo

type ResGetInfo struct {
	Error  *bchain.RPCError `json:"error"`
	Result struct {
		TransparentSupply json.Number `json:"transparentsupply"`
		ShieldSupply      json.Number `json:"shieldsupply"`
		MoneySupply       json.Number `json:"moneysupply"`
	} `json:"result"`
}

type ResGetMasternodeCount

type ResGetMasternodeCount struct {
	Error  *bchain.RPCError `json:"error"`
	Result struct {
		Total   int `json:"total"`
		Stable  int `json:"stable"`
		Enabled int `json:"enabled"`
		InQueue int `json:"inqueue"`
	} `json:"result"`
}

Jump to

Keyboard shortcuts

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