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 IsLiquid(network Network) bool
- func P2TRScript(taprootKey *secp256k1.PublicKey) ([]byte, error)
- func ValidateConnectors(roundTx string, connectors []string) 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 )
const MutinyNetBlockTime = time.Second * 30
Variables ¶
var Bitcoin = Network{
Name: "bitcoin",
Addr: "ark",
}
var BitcoinRegTest = Network{ Name: "regtest", Addr: BitcoinTestNet.Addr, }
var BitcoinSigNet = Network{ Name: "signet", Addr: BitcoinTestNet.Addr, }
var BitcoinTestNet = Network{
Name: "testnet",
Addr: "tark",
}
var ConnectorTxSize = (&input.TxWeightEstimator{}). AddTaprootKeySpendInput(txscript.SigHashDefault). AddP2TROutput(). AddP2TROutput(). VSize()
var CovenantTreeTxSize = TreeTxSize * 2
liquid node size is 2x the bitcoin node size (avoid min-relay-fee issues with the low fee rate on liquid)
var (
ErrWrongDescriptor = errors.New("wrong descriptor, cannot parse vtxo script")
)
var Liquid = Network{
Name: "liquid",
Addr: "ark",
}
var LiquidRegTest = Network{ Name: "liquidregtest", Addr: LiquidTestNet.Addr, }
var LiquidTestNet = Network{
Name: "liquidtestnet",
Addr: "tark",
}
var MutinyNetChallenge = []byte{
0x51, 0x21, 0x02, 0xf7, 0x56, 0x1d, 0x20, 0x8d, 0xd9, 0xae, 0x99, 0xbf,
0x49, 0x72, 0x73, 0xe1, 0x6f, 0x38, 0x9b, 0xdb, 0xd6, 0xc4, 0x74, 0x2d,
0xdb, 0x8e, 0x6b, 0x21, 0x6e, 0x64, 0xfa, 0x29, 0x28, 0xad, 0x8f, 0x51,
0xae,
}
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 ¶
func P2TRScript ¶
func ValidateConnectors ¶
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 { HRP string Server *secp256k1.PublicKey VtxoTapKey *secp256k1.PublicKey }
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 the implementation depends on the chain (liquid or bitcoin)
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