gleecbtc

package
v0.0.0-...-cbc739f Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 41 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// RedeemP2PKHSigScriptSize is the worst case (largest) serialize size
	// of a transaction input script that redeems a compressed P2PKH output.
	// It is calculated as:
	//
	//   - OP_DATA_73
	//   - 72 bytes DER signature + 1 byte sighash
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	RedeemP2PKHSigScriptSize = 1 + 73 + 1 + 33

	// RedeemP2SHMultisigSigScriptSize is the worst case (largest) serialize size
	// of a transaction input script that redeems a 2 of 3 P2SH multisig output with compressed keys.
	// It is calculated as:
	//
	//   - OP_0
	//   - OP_DATA_72
	//   - 72 bytes DER signature
	//   - OP_DATA_72
	//   - 72 bytes DER signature
	//   - OP_PUSHDATA
	//   - OP_2
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP3
	//   - OP_CHECKMULTISIG
	RedeemP2SH2of3MultisigSigScriptSize = 1 + 1 + 72 + 1 + 72 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1

	// RedeemP2SH1of2MultisigSigScriptSize is the worst case (largest) serialize size
	// of a transaction input script that redeems a 1 of 2 P2SH multisig output with compressed keys.
	// It is calculated as:
	//
	//   - OP_0
	//   - OP_DATA_72
	//   - 72 bytes DER signature
	//   - OP_PUSHDATA
	//   - OP_1
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP2
	//   - OP_CHECKMULTISIG
	RedeemP2SH1of2MultisigSigScriptSize = 1 + 1 + 72 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 1

	// RedeemP2SHMultisigTimelock1SigScriptSize is the worst case (largest) serialize size
	// of a transaction input script that redeems a compressed P2SH timelocked multisig using the timeout.
	// It is calculated as:
	//
	//   - OP_DATA_72
	//   - 72 bytes DER signature
	//   - OP_0
	//   - OP_PUSHDATA
	//   - OP_IF
	//   - OP_2
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP3
	//   - OP_CHECKMULTISIG
	//   - OP_ELSE
	//   - OP_PUSHDATA
	//   - 2 byte block height
	//   - OP_CHECKSEQUENCEVERIFY
	//   - OP_DROP
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_CHECKSIG
	//   - OP_ENDIF
	RedeemP2SHMultisigTimelock1SigScriptSize = 1 + 72 + 1 + 1 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 33 + 1 + 1

	// RedeemP2SHMultisigTimelock2SigScriptSize is the worst case (largest) serialize size
	// of a transaction input script that redeems a compressed P2SH timelocked multisig without using the timeout.
	// It is calculated as:
	//
	//   - OP_0
	//   - OP_DATA_72
	//   - 72 bytes DER signature
	//   - OP_DATA_72
	//   - 72 bytes DER signature
	//   - OP_1
	//   - OP_PUSHDATA
	//   - OP_IF
	//   - OP_2
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP3
	//   - OP_CHECKMULTISIG
	//   - OP_ELSE
	//   - OP_PUSHDATA
	//   - 2 byte block height
	//   - OP_CHECKSEQUENCEVERIFY
	//   - OP_DROP
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	//   - OP_CHECKSIG
	//   - OP_ENDIF
	RedeemP2SHMultisigTimelock2SigScriptSize = 1 + 1 + 72 + +1 + 72 + 1 + 1 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 33 + 1 + 1

	// P2PKHPkScriptSize is the size of a transaction output script that
	// pays to a compressed pubkey hash.  It is calculated as:
	//
	//   - OP_DUP
	//   - OP_HASH160
	//   - OP_DATA_20
	//   - 20 bytes pubkey hash
	//   - OP_EQUALVERIFY
	//   - OP_CHECKSIG
	P2PKHPkScriptSize = 1 + 1 + 1 + 20 + 1 + 1

	// RedeemP2PKHInputSize is the worst case (largest) serialize size of a
	// transaction input redeeming a compressed P2PKH output.  It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte script len
	//   - signature script
	//   - 4 bytes sequence
	RedeemP2PKHInputSize = 32 + 4 + 1 + RedeemP2PKHSigScriptSize + 4

	// RedeemP2SH2of3MultisigInputSize is the worst case (largest) serialize size of a
	// transaction input redeeming a compressed P2SH 2 of 3 multisig output.  It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte script len
	//   - 4 bytes sequence
	///  - witness discounted signature script
	RedeemP2SH2of3MultisigInputSize = 32 + 4 + 1 + 4 + (RedeemP2SH2of3MultisigSigScriptSize / 4)

	// RedeemP2SH1of2MultisigInputSize is the worst case (largest) serialize size of a
	// transaction input redeeming a compressed P2SH 2 of 3 multisig output.  It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte script len
	//   - 4 bytes sequence
	///  - witness discounted signature script
	RedeemP2SH1of2MultisigInputSize = 32 + 4 + 1 + 4 + (RedeemP2SH1of2MultisigSigScriptSize / 4)

	// RedeemP2SHMultisigTimelock1InputSize is the worst case (largest) serialize size of a
	// transaction input redeeming a compressed p2sh timelocked multig output with using the timeout.  It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte script len
	//   - 4 bytes sequence
	///  - witness discounted signature script
	RedeemP2SHMultisigTimelock1InputSize = 32 + 4 + 1 + 4 + (RedeemP2SHMultisigTimelock1SigScriptSize / 4)

	// RedeemP2SHMultisigTimelock2InputSize is the worst case (largest) serialize size of a
	// transaction input redeeming a compressed P2SH timelocked multisig output without using the timeout.  It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte script len
	//   - 4 bytes sequence
	///  - witness discounted signature script
	RedeemP2SHMultisigTimelock2InputSize = 32 + 4 + 1 + 4 + (RedeemP2SHMultisigTimelock2SigScriptSize / 4)

	// P2PKHOutputSize is the serialize size of a transaction output with a
	// P2PKH output script.  It is calculated as:
	//
	//   - 8 bytes output value
	//   - 1 byte compact int encoding value 25
	//   - 25 bytes P2PKH output script
	P2PKHOutputSize = 8 + 1 + P2PKHPkScriptSize
)

Worst case script and input/output size estimates.

Variables

View Source
var (
	LitecoinCurrencyDefinition = wi.CurrencyDefinition{
		Code:         "LTC",
		Divisibility: 8,
	}
)

Functions

func EstimateSerializeSize

func EstimateSerializeSize(inputCount int, txOuts []*wire.TxOut, addChangeOutput bool, inputType InputType) int

EstimateSerializeSize returns a worst case serialize size estimate for a signed transaction that spends inputCount number of compressed P2PKH outputs and contains each transaction output from txOuts. The estimated size is incremented for an additional P2PKH change output if addChangeOutput is true.

func NormalizeCurrencyCode

func NormalizeCurrencyCode(currencyCode string) string

NormalizeCurrencyCode standardizes the format for the given currency code

func SumOutputSerializeSizes

func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int)

SumOutputSerializeSizes sums up the serialized size of the supplied outputs.

Types

type BitfinexDecoder

type BitfinexDecoder struct{}

type BittrexDecoder

type BittrexDecoder struct{}

type ExchangeRateDecoder

type ExchangeRateDecoder interface {
	// contains filtered or unexported methods
}

type ExchangeRateProvider

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

type InputType

type InputType int
const (
	P2PKH InputType = iota
	P2SH_1of2_Multisig
	P2SH_2of3_Multisig
	P2SH_Multisig_Timelock_1Sig
	P2SH_Multisig_Timelock_2Sigs
)

type KrakenDecoder

type KrakenDecoder struct{}

type LitecoinPriceFetcher

type LitecoinPriceFetcher struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewLitecoinPriceFetcher

func NewLitecoinPriceFetcher(dialer proxy.Dialer) *LitecoinPriceFetcher

func (*LitecoinPriceFetcher) GetAllRates

func (z *LitecoinPriceFetcher) GetAllRates(cacheOK bool) (map[string]float64, error)

func (*LitecoinPriceFetcher) GetExchangeRate

func (z *LitecoinPriceFetcher) GetExchangeRate(currencyCode string) (float64, error)

func (*LitecoinPriceFetcher) GetLatestRate

func (z *LitecoinPriceFetcher) GetLatestRate(currencyCode string) (float64, error)

func (*LitecoinPriceFetcher) UnitsPerCoin

func (z *LitecoinPriceFetcher) UnitsPerCoin() int64

type LitecoinWallet

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

func NewLitecoinWallet

func NewLitecoinWallet(cfg config.CoinConfig, mnemonic string, params *chaincfg.Params, proxy proxy.Dialer, cache cache.Cacher, disableExchangeRates bool) (*LitecoinWallet, error)

func (*LitecoinWallet) AddTransactionListener

func (w *LitecoinWallet) AddTransactionListener(callback func(wi.TransactionCallback))

func (*LitecoinWallet) AddWatchedAddresses

func (w *LitecoinWallet) AddWatchedAddresses(addrs ...btcutil.Address) error

func (*LitecoinWallet) AddWatchedScript

func (w *LitecoinWallet) AddWatchedScript(script []byte) error

func (*LitecoinWallet) AddressToScript

func (w *LitecoinWallet) AddressToScript(addr btcutil.Address) ([]byte, error)

func (*LitecoinWallet) AssociateTransactionWithOrder

func (w *LitecoinWallet) AssociateTransactionWithOrder(cb wi.TransactionCallback)

AssociateTransactionWithOrder used for ORDER_PAYMENT message

func (*LitecoinWallet) Balance

func (*LitecoinWallet) Broadcast

func (w *LitecoinWallet) Broadcast(tx *wire.MsgTx) error

Build a client.Transaction so we can ingest it into the wallet service then broadcast

func (*LitecoinWallet) BumpFee

func (w *LitecoinWallet) BumpFee(txid chainhash.Hash) (*chainhash.Hash, error)

func (*LitecoinWallet) ChainTip

func (w *LitecoinWallet) ChainTip() (uint32, chainhash.Hash)

func (*LitecoinWallet) ChildKey

func (w *LitecoinWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey bool) (*hd.ExtendedKey, error)

func (*LitecoinWallet) Close

func (w *LitecoinWallet) Close()

func (*LitecoinWallet) CreateMultisigSignature

func (w *LitecoinWallet) CreateMultisigSignature(ins []wi.TransactionInput, outs []wi.TransactionOutput, key *hd.ExtendedKey, redeemScript []byte, feePerByte big.Int) ([]wi.Signature, error)

func (*LitecoinWallet) CurrencyCode

func (w *LitecoinWallet) CurrencyCode() string

func (*LitecoinWallet) CurrentAddress

func (w *LitecoinWallet) CurrentAddress(purpose wi.KeyPurpose) btcutil.Address

func (*LitecoinWallet) DecodeAddress

func (w *LitecoinWallet) DecodeAddress(addr string) (btcutil.Address, error)

func (*LitecoinWallet) DumpTables

func (w *LitecoinWallet) DumpTables(wr io.Writer)

func (*LitecoinWallet) EstimateFee

func (w *LitecoinWallet) EstimateFee(ins []wi.TransactionInput, outs []wi.TransactionOutput, feePerByte big.Int) big.Int

func (*LitecoinWallet) EstimateSpendFee

func (w *LitecoinWallet) EstimateSpendFee(amount big.Int, feeLevel wi.FeeLevel) (big.Int, error)

func (*LitecoinWallet) ExchangeRates

func (w *LitecoinWallet) ExchangeRates() wi.ExchangeRates

func (*LitecoinWallet) GenerateMultisigScript

func (w *LitecoinWallet) GenerateMultisigScript(keys []hd.ExtendedKey, threshold int, timeout time.Duration, timeoutKey *hd.ExtendedKey) (addr btcutil.Address, redeemScript []byte, err error)

func (*LitecoinWallet) GetConfirmations

func (w *LitecoinWallet) GetConfirmations(txid chainhash.Hash) (uint32, uint32, error)

func (*LitecoinWallet) GetFeePerByte

func (w *LitecoinWallet) GetFeePerByte(feeLevel wi.FeeLevel) big.Int

func (*LitecoinWallet) GetTransaction

func (w *LitecoinWallet) GetTransaction(txid chainhash.Hash) (wi.Txn, error)

func (*LitecoinWallet) HasKey

func (w *LitecoinWallet) HasKey(addr btcutil.Address) bool

func (*LitecoinWallet) IsDust

func (w *LitecoinWallet) IsDust(amount big.Int) bool

func (*LitecoinWallet) MasterPrivateKey

func (w *LitecoinWallet) MasterPrivateKey() *hd.ExtendedKey

func (*LitecoinWallet) MasterPublicKey

func (w *LitecoinWallet) MasterPublicKey() *hd.ExtendedKey

func (*LitecoinWallet) Multisign

func (w *LitecoinWallet) Multisign(ins []wi.TransactionInput, outs []wi.TransactionOutput, sigs1 []wi.Signature, sigs2 []wi.Signature, redeemScript []byte, feePerByte big.Int, broadcast bool) ([]byte, error)

func (*LitecoinWallet) NewAddress

func (w *LitecoinWallet) NewAddress(purpose wi.KeyPurpose) btcutil.Address

func (*LitecoinWallet) Params

func (w *LitecoinWallet) Params() *chaincfg.Params

func (*LitecoinWallet) ReSyncBlockchain

func (w *LitecoinWallet) ReSyncBlockchain(fromTime time.Time)

func (*LitecoinWallet) ScriptToAddress

func (w *LitecoinWallet) ScriptToAddress(script []byte) (btcutil.Address, error)

func (*LitecoinWallet) Spend

func (w *LitecoinWallet) Spend(amount big.Int, addr btcutil.Address, feeLevel wi.FeeLevel, referenceID string, spendAll bool) (*chainhash.Hash, error)

func (*LitecoinWallet) Start

func (w *LitecoinWallet) Start()

func (*LitecoinWallet) SweepAddress

func (w *LitecoinWallet) SweepAddress(ins []wi.TransactionInput, address *btcutil.Address, key *hd.ExtendedKey, redeemScript *[]byte, feeLevel wi.FeeLevel) (*chainhash.Hash, error)

func (*LitecoinWallet) Transactions

func (w *LitecoinWallet) Transactions() ([]wi.Txn, error)

type PoloniexDecoder

type PoloniexDecoder struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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