Documentation
¶
Index ¶
- Constants
- Variables
- func AppDataDir(appName string, roaming bool) string
- func BIP68Sequence(locktime RelativeLocktime) (uint32, error)
- func ComputeForfeitTxFee(feeRate chainfee.SatPerKVByte, tapscript *waddrmgr.Tapscript, witnessSize int, ...) (uint64, error)
- func ComputeRedeemTxFee(feeRate chainfee.SatPerKVByte, vtxos []VtxoInput, numOutputs int) (int64, error)
- func P2TRScript(taprootKey *secp256k1.PublicKey) ([]byte, error)
- type AbsoluteLocktime
- type Address
- type Network
- type RelativeLocktime
- type RelativeLocktimeType
- type TaprootMerkleProof
- type TaprootTree
- type VtxoInput
- type VtxoScript
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 ConnectorTxSize = (&input.TxWeightEstimator{}). AddTaprootKeySpendInput(txscript.SigHashDefault). AddP2TROutput(). AddP2TROutput(). AddP2TROutput(). AddP2TROutput(). VSize()
var (
ErrWrongDescriptor = errors.New("wrong descriptor, cannot parse vtxo script")
)
var MutinyNetSigNetParams = func() chaincfg.Params { params := chaincfg.CustomSignetParams(mutinyNetChallenge, nil) params.TargetTimePerBlock = mutinyNetBlockTime return params }()
var TreeTxSize = (&input.TxWeightEstimator{}). AddTaprootKeySpendInput(txscript.SigHashDefault). AddP2TROutput(). AddP2TROutput(). VSize()
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)
func ComputeForfeitTxFee ¶
func ComputeForfeitTxFee( feeRate chainfee.SatPerKVByte, tapscript *waddrmgr.Tapscript, witnessSize int, serverScriptClass txscript.ScriptClass, ) (uint64, error)
func ComputeRedeemTxFee ¶
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 ¶
Address represents an Ark address with HRP, server public key, and VTXO Taproot public key
func DecodeAddress ¶
DecodeAddress parses a bech32m encoded address string and returns an Address object
type RelativeLocktime ¶
type RelativeLocktime struct {
Type RelativeLocktimeType
Value uint32
}
RelativeLocktime represents a BIP68 relative timelock value
func BIP68DecodeSequence ¶
func BIP68DecodeSequence(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 knowning 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(server *secp256k1.PublicKey, minLocktime RelativeLocktime) error TapTree() (taprootKey *secp256k1.PublicKey, taprootScriptTree T, err error) Encode() ([]string, error) Decode(scripts []string) error SmallestExitDelay() (*RelativeLocktime, error) ForfeitClosures() []C ExitClosures() []C }
A vtxo script is defined as a taproot contract with at least 1 forfeit closure (User && Server) and 1 exit closure (A after t). It may also contain others closures implementing specific use cases.
VtxoScript abstracts the taproot complexity behind vtxo contracts. it is compiled, transferred and parsed using descriptor string.
// TODO gather common and tree package to prevent circular dependency and move C generic