bitcoin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainBitcoin  = 1
	ChainLitecoin = 5

	ValuePrecision = 8
	ValueSatoshi   = 100000000

	TimeLockMinimum = time.Hour * 1
	TimeLockMaximum = time.Hour * 24 * 365

	ScriptPubKeyTypeWitnessKeyHash    = "witness_v0_keyhash"
	ScriptPubKeyTypeWitnessScriptHash = "witness_v0_scripthash"
	SigHashType                       = txscript.SigHashAll | txscript.SigHashAnyOneCanPay

	InputTypeP2WPKHAccoutant             = 1
	InputTypeP2WSHMultisigHolderSigner   = 2
	InputTypeP2WSHMultisigObserverSigner = 3

	MaxTransactionSequence = 0xffffffff
	MaxStandardTxWeight    = 300000

	TransactionConfirmations = 1
)
View Source
const (
	CoinBitcoin  = 0
	CoinLitecoin = 2
)

Variables

This section is empty.

Functions

func BitcoinDefaultDerivationPath

func BitcoinDefaultDerivationPath() []byte

func CheckDerivation

func CheckDerivation(public string, chainCode []byte, maxRange uint32) error

func CheckFinalization

func CheckFinalization(num uint64, coinbase bool) bool

func CheckTransactionPartiallySignedBy

func CheckTransactionPartiallySignedBy(raw, public string) bool

func DeriveBIP32

func DeriveBIP32(public string, chainCode []byte, children ...uint32) (string, string, error)

func DeriveBIP32WithPath

func DeriveBIP32WithPath(public, chaincode string, path8 []byte) (string, error)

func EstimateTransactionFee

func EstimateTransactionFee(mainInputs []*Input, feeInputs []*Input, outputs []*Output, fvb int64, rid []byte, chain byte) (int64, error)

func HashMessageForSignature

func HashMessageForSignature(msg string, chain byte) ([]byte, error)

func IsInsufficientInputError

func IsInsufficientInputError(err error) bool

func MarshalWiredTransaction

func MarshalWiredTransaction(msgTx *wire.MsgTx, encoding wire.MessageEncoding, chain byte) ([]byte, error)

func ParseAddress

func ParseAddress(addr string, chain byte) ([]byte, error)

func ParseSatoshi

func ParseSatoshi(amount string) (int64, error)

func ParseSequence

func ParseSequence(lock time.Duration, chain byte) (int64, error)

func RPCEstimateSmartFee

func RPCEstimateSmartFee(chain byte, rpc string) (int64, error)

func RPCGetBlockHash

func RPCGetBlockHash(rpc string, num int64) (string, error)

func RPCGetBlockHeight

func RPCGetBlockHeight(rpc string) (int64, error)

func RPCGetTransactionOutput

func RPCGetTransactionOutput(chain byte, rpc, hash string, index int64) (*RPCTransaction, *Output, error)

func RPCGetTransactionSender

func RPCGetTransactionSender(chain byte, rpc string, tx *RPCTransaction) (string, error)

func RPCSendRawTransaction

func RPCSendRawTransaction(rpc, raw string) (string, error)

func SignTx

func SignTx(rawStr, privateStr string, chain byte) (string, error)

func ValueDust

func ValueDust(chain byte) (int64, error)

func VerifyAddress

func VerifyAddress(address string, coin uint32) error

func VerifySignatureDER

func VerifySignatureDER(public string, msg, sig []byte) error

func WriteBytes

func WriteBytes(enc *common.Encoder, b []byte)

Types

type Input

type Input struct {
	TransactionHash string
	Index           uint32
	Satoshi         int64
	Script          []byte
	Sequence        uint32
	RouteBackup     bool
}

type Output

type Output struct {
	Address  string
	Satoshi  int64
	Height   uint64
	Time     time.Time
	Coinbase bool
}

type PartiallySignedTransaction

type PartiallySignedTransaction struct {
	*psbt.Packet
}

func BuildPartiallySignedTransaction

func BuildPartiallySignedTransaction(mainInputs []*Input, outputs []*Output, rid []byte, chain byte) (*PartiallySignedTransaction, error)

func UnmarshalPartiallySignedTransaction

func UnmarshalPartiallySignedTransaction(b []byte) (*PartiallySignedTransaction, error)

func (*PartiallySignedTransaction) Hash

func (raw *PartiallySignedTransaction) Hash() string

func (*PartiallySignedTransaction) Marshal

func (raw *PartiallySignedTransaction) Marshal() ([]byte, error)

func (*PartiallySignedTransaction) SigHash

func (psbt *PartiallySignedTransaction) SigHash(idx int) ([]byte, error)

type RPCBlock

type RPCBlock struct {
	Hash   string   `json:"hash"`
	Height uint64   `json:"height"`
	Tx     []string `json:"tx"`
	Time   int64    `json:"time"`
}

func RPCGetBlock

func RPCGetBlock(rpc, hash string) (*RPCBlock, error)

type RPCBlockWithTransactions

type RPCBlockWithTransactions struct {
	Hash   string            `json:"hash"`
	Height uint64            `json:"height"`
	Tx     []*RPCTransaction `json:"tx"`
}

func RPCGetBlockWithTransactions

func RPCGetBlockWithTransactions(chain byte, rpc, hash string) (*RPCBlockWithTransactions, error)

type RPCTransaction

type RPCTransaction struct {
	TxId      string    `json:"txid"`
	Vin       []*rpcIn  `json:"vin"`
	Vout      []*rpcOut `json:"vout"`
	BlockHash string    `json:"blockhash"`
	Hex       string    `json:"hex"`
}

func RPCGetRawMempool

func RPCGetRawMempool(chain byte, rpc string) ([]*RPCTransaction, error)

func RPCGetTransaction

func RPCGetTransaction(chain byte, rpc, hash string) (*RPCTransaction, error)

Jump to

Keyboard shortcuts

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