{"modulePath":"github.com/lightninglabs/loop","version":"v0.36.0-beta","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package script\n\n## Constants\n\n```go\nconst (\n\t// TaprootMultiSigWitnessSize evaluates to 66 bytes:\n\t//\t- num_witness_elements: 1 byte\n\t//\t- sig_varint_len: 1 byte\n\t//\t- \u003csig\u003e: 64 bytes\n\tTaprootMultiSigWitnessSize = 1 + 1 + 64\n\n\t// TaprootExpiryScriptSize evaluates to 39 bytes:\n\t//\t- OP_DATA: 1 byte (client_key length)\n\t//\t- \u003cclient_key\u003e: 32 bytes\n\t//\t- OP_CHECKSIGVERIFY: 1 byte\n\t//\t- \u003caddress_expiry\u003e: 4 bytes\n\t//\t- OP_CHECKSEQUENCEVERIFY: 1 byte\n\tTaprootExpiryScriptSize = 1 + 32 + 1 + 4 + 1\n\n\t// TaprootExpiryWitnessSize evaluates to 140 bytes:\n\t//\t- num_witness_elements: 1 byte\n\t//\t- client_sig_varint_len: 1 byte (client_sig length)\n\t//\t- \u003ctrader_sig\u003e: 64 bytes\n\t//\t- witness_script_varint_len: 1 byte (script length)\n\t//\t- \u003cwitness_script\u003e: 39 bytes\n\t//\t- control_block_varint_len: 1 byte (control block length)\n\t//\t- \u003ccontrol_block\u003e: 33 bytes\n\tTaprootExpiryWitnessSize = 1 + 1 + 64 + 1 + TaprootExpiryScriptSize + 1 + 33\n)\n```\n\n## Functions\n\n```go\nfunc ExpirySpendWeight() int64\n```\nExpirySpendWeight returns the weight of the expiry path spend.\n\n```go\nfunc GenTimeoutPathScript(clientKey *btcec.PublicKey, csvExpiry int64) ([]byte,\n\terror)\n```\nGenTimeoutPathScript constructs a csv timeout script for the client.\n\n\t\u003cclientKey\u003e OP_CHECKSIGVERIFY \u003ccsvExpiry\u003e OP_CHECKSEQUENCEVERIFY\n\n## Types\n\n```go\ntype Parameters struct {\n\t// ID is the database primary key of the static address row. A zero value\n\t// means the parameters have not been persisted yet.\n\tID int32\n\n\t// ClientPubkey is the client's pubkey for the static address. It is\n\t// used for the 2-of-2 funding output as well as for the client's\n\t// timeout path.\n\tClientPubkey *btcec.PublicKey\n\n\t// ServerPubkey is the server's pubkey for the static address. It is\n\t// used for the 2-of-2 funding output.\n\tServerPubkey *btcec.PublicKey\n\n\t// Expiry is the CSV timeout value at which the client can claim the\n\t// static address's timeout path.\n\tExpiry uint32\n\n\t// PkScript is the unique static address's output script.\n\tPkScript []byte\n\n\t// KeyLocator is the locator of the client's key.\n\tKeyLocator keychain.KeyLocator\n\n\t// ProtocolVersion is the protocol version of the static address.\n\tProtocolVersion version.AddressProtocolVersion\n\n\t// InitiationHeight is the height at which the address was initiated.\n\tInitiationHeight int32\n}\n```\nParameters holds all the necessary information for the 2-of-2 multisig address.\n\n```go\nfunc (p *Parameters) StaticAddress() (*StaticAddress, error)\n```\nStaticAddress reconstructs the spending script for these address parameters.\n\n```go\ntype StaticAddress struct {\n\t// TimeoutScript is the final locking script for the timeout path which\n\t// is available to the sender after the set block height.\n\tTimeoutScript []byte\n\n\t// TimeoutLeaf is the timeout leaf.\n\tTimeoutLeaf *txscript.TapLeaf\n\n\t// ScriptTree is the assembled script tree from our timeout leaf.\n\tScriptTree *txscript.IndexedTapScriptTree\n\n\t// InternalPubKey is the public key for the keyspend path which bypasses\n\t// the timeout script locking.\n\tInternalPubKey *btcec.PublicKey\n\n\t// TaprootKey is the taproot public key which is created with the above\n\t// 3 inputs.\n\tTaprootKey *btcec.PublicKey\n\n\t// RootHash is the root hash of the taptree.\n\tRootHash chainhash.Hash\n}\n```\nStaticAddress encapsulates the static address script.\n\n```go\nfunc NewStaticAddress(muSig2Version input.MuSig2Version, csvExpiry int64,\n\tclientPubKey, serverPubKey *btcec.PublicKey) (*StaticAddress, error)\n```\nNewStaticAddress constructs a static address script.\n\n```go\nfunc (s *StaticAddress) GenSuccessWitness(combinedSig []byte) (wire.TxWitness,\n\terror)\n```\nGenSuccessWitness returns the success witness to spend the static address output with a combined signature.\n\n```go\nfunc (s *StaticAddress) GenTimeoutWitness(senderSig []byte) (wire.TxWitness,\n\terror)\n```\nGenTimeoutWitness returns the witness to spend the taproot timeout leaf.\n\n```go\nfunc (s *StaticAddress) StaticAddressScript() ([]byte, error)\n```\nStaticAddressScript creates a MuSig2 2-of-2 multisig script with CSV timeout path for the clientKey. This script represents a static loop-in address.\n\n","path":"github.com/lightninglabs/loop/staticaddr/script","name":"script","synopsis":"","isRedistributable":true}
