loop/staticaddr/address/interface.go

56 lines
1.7 KiB
Go
Raw Normal View History

2024-03-07 17:27:13 +01:00
package address
2023-11-09 19:07:48 +01:00
import (
"context"
"github.com/btcsuite/btcd/btcec/v2"
2024-03-07 17:27:13 +01:00
"github.com/lightninglabs/loop/staticaddr/version"
2023-11-09 19:07:48 +01:00
"github.com/lightningnetwork/lnd/keychain"
)
2024-03-07 17:27:13 +01:00
// Store is the database interface that is used to store and retrieve
2023-11-09 19:07:48 +01:00
// static addresses.
2024-03-07 17:27:13 +01:00
type Store interface {
2023-11-09 19:07:48 +01:00
// CreateStaticAddress inserts a new static address with its parameters
// into the store.
2024-03-07 17:27:13 +01:00
CreateStaticAddress(ctx context.Context, addrParams *Parameters) error
2023-11-09 19:07:48 +01:00
// GetStaticAddress fetches static address parameters for a given
// address ID.
2024-03-07 17:27:13 +01:00
GetStaticAddress(ctx context.Context, pkScript []byte) (*Parameters,
error)
2023-11-09 19:07:48 +01:00
// GetAllStaticAddresses retrieves all static addresses from the store.
2024-03-07 17:27:13 +01:00
GetAllStaticAddresses(ctx context.Context) ([]*Parameters,
error)
2023-11-09 19:07:48 +01:00
}
2024-03-07 17:27:13 +01:00
// Parameters holds all the necessary information for the 2-of-2 multisig
2023-11-09 19:07:48 +01:00
// address.
2024-03-07 17:27:13 +01:00
type Parameters struct {
2023-11-09 19:07:48 +01:00
// ClientPubkey is the client's pubkey for the static address. It is
// used for the 2-of-2 funding output as well as for the client's
// timeout path.
ClientPubkey *btcec.PublicKey
// ClientPubkey is the client's pubkey for the static address. It is
// used for the 2-of-2 funding output.
ServerPubkey *btcec.PublicKey
// Expiry is the CSV timout value at which the client can claim the
// static address's timout path.
Expiry uint32
// PkScript is the unique static address's output script.
PkScript []byte
// KeyLocator is the locator of the client's key.
KeyLocator keychain.KeyLocator
// ProtocolVersion is the protocol version of the static address.
2024-03-07 17:27:13 +01:00
ProtocolVersion version.AddressProtocolVersion
// InitiationHeight is the height at which the address was initiated.
InitiationHeight int32
2023-11-09 19:07:48 +01:00
}