bitcoin

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 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
)

Variables

This section is empty.

Functions

func CanonicalSignatureDER added in v0.6.1

func CanonicalSignatureDER(sig []byte) ([]byte, error)

func CheckDerivation added in v0.5.0

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

func CheckFinalization

func CheckFinalization(num uint64, coinbase bool) bool

func CheckMultisigHolderSignerScript

func CheckMultisigHolderSignerScript(script []byte) bool

func CheckTransactionPartiallySignedBy added in v0.5.0

func CheckTransactionPartiallySignedBy(raw, public string) bool

func DeriveBIP32 added in v0.4.1

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

func EncodeAddress

func EncodeAddress(script []byte, chain byte) (string, error)

func ExtractPkScriptAddr added in v0.8.0

func ExtractPkScriptAddr(pkScript []byte, chain byte) (string, error)

func HashMessageForSignature

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

func IsInsufficientInputError

func IsInsufficientInputError(err error) bool

func MarshalWiredTransaction added in v0.5.0

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

func ParseSequence

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

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 SpendSignedTransaction added in v0.5.0

func SpendSignedTransaction(raw string, feeInputs []*Input, accountant string, chain byte) (*wire.MsgTx, error)

func ValueDust

func ValueDust(chain byte) int64

func VerifyHolderKey

func VerifyHolderKey(public string) error

func VerifySignatureDER

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

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
	Coinbase bool
}

type PartiallySignedTransaction

type PartiallySignedTransaction struct {
	*psbt.Packet
}

func BuildPartiallySignedTransaction

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

func SignPartiallySignedTransaction added in v0.8.0

func SignPartiallySignedTransaction(raw []byte, signer *secp256k1.PrivateKey) *PartiallySignedTransaction

func UnmarshalPartiallySignedTransaction

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

func (*PartiallySignedTransaction) Hash

func (raw *PartiallySignedTransaction) Hash() string

func (*PartiallySignedTransaction) IsRecoveryTransaction added in v0.8.0

func (psbt *PartiallySignedTransaction) IsRecoveryTransaction() bool

func (*PartiallySignedTransaction) Marshal

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

func (*PartiallySignedTransaction) SigHash

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

func (*PartiallySignedTransaction) SignedTransaction added in v0.5.0

func (psbt *PartiallySignedTransaction) SignedTransaction(holder, signer, observer string) (*wire.MsgTx, error)

type RPCBlock

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

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)

type WitnessScriptAccount

type WitnessScriptAccount struct {
	Sequence uint32
	Script   []byte
	Address  string
}

func BuildWitnessScriptAccount

func BuildWitnessScriptAccount(holder, signer, observer string, lock time.Duration, chain byte) (*WitnessScriptAccount, error)

thresh(2,pk(HOLDER),pk(SIGNER),and(pk(OBSERVER),older(12960))) thresh(2,pk(HOLDER),s:pk(SIGNER),sj:and_v(v:pk(OBSERVER),n:older(12960)))

<HOLDER> OP_CHECKSIG OP_SWAP <SIGNER> OP_CHECKSIG OP_ADD OP_SWAP OP_SIZE OP_0NOTEQUAL OP_IF <OBSERVER> OP_CHECKSIGVERIFY <a032> OP_CHECKSEQUENCEVERIFY OP_0NOTEQUAL OP_ENDIF OP_ADD 2 OP_EQUAL

func UnmarshalWitnessScriptAccount added in v0.5.0

func UnmarshalWitnessScriptAccount(extra []byte) (*WitnessScriptAccount, error)

func (*WitnessScriptAccount) Marshal added in v0.5.0

func (wsa *WitnessScriptAccount) Marshal() []byte

Jump to

Keyboard shortcuts

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