Documentation
¶
Index ¶
Constants ¶
const ( SEQUENCE_LOCKTIME_MASK = 0x0000ffff SEQUENCE_LOCKTIME_TYPE_FLAG = 1 << 22 SEQUENCE_LOCKTIME_GRANULARITY = 9 SECONDS_MOD = 1 << SEQUENCE_LOCKTIME_GRANULARITY SECONDS_MAX = SEQUENCE_LOCKTIME_MASK << SEQUENCE_LOCKTIME_GRANULARITY SEQUENCE_LOCKTIME_DISABLE_FLAG = 1 << 31 SECONDS_PER_BLOCK = 10 * 60 // 10 minutes )
Variables ¶
var Bitcoin = Network{
Name: "bitcoin",
Addr: "ark",
}
var BitcoinMutinyNet = Network{ Name: "mutinynet", Addr: BitcoinTestNet.Addr, }
var BitcoinRegTest = Network{ Name: "regtest", Addr: BitcoinTestNet.Addr, }
var BitcoinSigNet = Network{ Name: "signet", Addr: BitcoinTestNet.Addr, }
var BitcoinTestNet = Network{
Name: "testnet",
Addr: "tark",
}
var BitcoinTestNet4 = Network{ Name: "testnet4", Addr: BitcoinTestNet.Addr, }
var MutinyNetSigNetParams = func() chaincfg.Params { params := chaincfg.CustomSignetParams(mutinyNetChallenge, nil) params.TargetTimePerBlock = mutinyNetBlockTime return params }()
Functions ¶
func AppDataDir ¶
AppDataDir returns an operating system specific directory to be used for storing application data for an application.
The appName parameter is the name of the application the data directory is being requested for. This function will prepend a period to the appName for POSIX style operating systems since that is standard practice. An empty appName or one with a single dot is treated as requesting the current directory so only "." will be returned. Further, the first character of appName will be made lowercase for POSIX style operating systems and uppercase for Mac and Windows since that is standard practice.
The roaming parameter only applies to Windows where it specifies the roaming application data profile (%APPDATA%) should be used instead of the local one (%LOCALAPPDATA%) that is used by default.
Example results:
dir := AppDataDir("myapp", false)
POSIX (Linux/BSD): ~/.myapp
Mac OS: $HOME/Library/Application Support/Myapp
Windows: %LOCALAPPDATA%\Myapp
Plan 9: $home/myapp
func BIP68Sequence ¶
func BIP68Sequence(locktime RelativeLocktime) (uint32, error)
Types ¶
type AbsoluteLocktime ¶
type AbsoluteLocktime uint32
AbsoluteLocktime represents an nLocktime value it is used as argument to a CheckLocktimeVerify opcode
func (AbsoluteLocktime) IsSeconds ¶
func (l AbsoluteLocktime) IsSeconds() bool
type Address ¶
type Address struct {
Version uint8
HRP string
Signer *btcec.PublicKey
VtxoTapKey *btcec.PublicKey
}
Address represents an Ark address with Version, prefix, signer public key, and VTXO taproot key.
func DecodeAddressV0 ¶
DecodeAddressV0 parses a bech32m encoded address string and returns an Address struct.
func (*Address) GetPkScript ¶ added in v0.7.1
type RelativeLocktime ¶
type RelativeLocktime struct {
Type RelativeLocktimeType
Value uint32
}
RelativeLocktime represents a BIP68 relative timelock value
func BIP68DecodeSequence ¶
func BIP68DecodeSequence(sequenceNum uint32) (*RelativeLocktime, bool)
func BIP68DecodeSequenceFromBytes ¶
func BIP68DecodeSequenceFromBytes(sequence []byte) (*RelativeLocktime, error)
func (RelativeLocktime) Compare ¶
func (l RelativeLocktime) Compare(other RelativeLocktime) int
func (RelativeLocktime) LessThan ¶
func (l RelativeLocktime) LessThan(other RelativeLocktime) bool
LessThan returns true if this locktime is less than the other locktime
func (RelativeLocktime) Seconds ¶
func (l RelativeLocktime) Seconds() int64
type RelativeLocktimeType ¶
type RelativeLocktimeType uint
RelativeLocktimeType represents a BIP68 relative locktime it is passed as argument to CheckSequenceVerify opcode
const ( LocktimeTypeSecond RelativeLocktimeType = iota LocktimeTypeBlock )
type TaprootMerkleProof ¶
func BiggestLeafMerkleProof ¶
func BiggestLeafMerkleProof(t TaprootTree) (*TaprootMerkleProof, error)
BiggestLeafMerkleProof returns the leaf with the biggest witness size (for fee estimation) we need this to estimate the fee without knowing the exact leaf that will be spent
type TaprootTree ¶
type TaprootTree interface {
GetLeaves() []chainhash.Hash
GetTaprootMerkleProof(leafhash chainhash.Hash) (*TaprootMerkleProof, error)
GetRoot() chainhash.Hash
}
TaprootTree is an interface wrapping the methods needed to spend a vtxo taproot contract
type VtxoScript ¶
type VtxoScript[T TaprootTree, C interface{}] interface { Validate(signer *btcec.PublicKey, minLocktime RelativeLocktime, blockTypeAllowed bool) error TapTree() (taprootKey *btcec.PublicKey, taprootScriptTree T, err error) Encode() ([]string, error) Decode(scripts []string) error SmallestExitDelay() (*RelativeLocktime, error) ForfeitClosures() []C ExitClosures() []C }
VtxoScript abstracts the taproot complexity behind vtxo contracts.
A vtxo script is defined as a taproot contract with at least 1 collaborative closure (A + S) and 1 exit closure (A after t). It may also contain others closures implementing specific use cases.
TODO: gather common and tree package to prevent circular dependency and move C generic