Documentation ¶
Index ¶
- Variables
- type ErrCreatePolicy
- type ErrNotAValidPublicKey
- type ErrReloadPolicy
- type Policy
- func (p *Policy) AddToAllowlist(pubkey string) error
- func (p *Policy) AddToSuspiciousPeerList(pubkey string) error
- func (p *Policy) DisableSwaps() error
- func (p *Policy) EnableSwaps() error
- func (p *Policy) Get() Policy
- func (p *Policy) GetMinSwapAmountMsat() uint64
- func (p *Policy) GetReserveOnchainMsat() uint64
- func (p *Policy) IsPeerAllowed(peer string) bool
- func (p *Policy) IsPeerSuspicious(peer string) bool
- func (p *Policy) NewSwapsAllowed() bool
- func (p *Policy) ReloadFile() error
- func (p *Policy) RemoveFromAllowlist(pubkey string) error
- func (p *Policy) RemoveFromSuspiciousPeerList(pubkey string) error
- func (p *Policy) String() string
Constants ¶
This section is empty.
Variables ¶
var ErrNoPolicyFile error = fmt.Errorf("no policy file given")
Error definitions
Functions ¶
This section is empty.
Types ¶
type ErrCreatePolicy ¶
type ErrCreatePolicy string
func (ErrCreatePolicy) Error ¶
func (e ErrCreatePolicy) Error() string
type ErrNotAValidPublicKey ¶
type ErrNotAValidPublicKey string
func (ErrNotAValidPublicKey) Error ¶
func (e ErrNotAValidPublicKey) Error() string
type ErrReloadPolicy ¶
type ErrReloadPolicy string
func (ErrReloadPolicy) Error ¶
func (e ErrReloadPolicy) Error() string
type Policy ¶
type Policy struct { ReserveOnchainMsat uint64 `` /* 200-byte string literal not displayed */ PeerAllowlist []string `` /* 131-byte string literal not displayed */ SuspiciousPeerList []string `` /* 137-byte string literal not displayed */ AcceptAllPeers bool `` /* 160-byte string literal not displayed */ // MinSwapAmountMsat is the minimum swap amount in msat that is needed to // perform a swap. Below this amount it might be uneconomical to do a swap // due to the on-chain costs. // TODO: This can not be set in the policy by now but this is the place // where this value belongs. Eventually we might want to make this value // editable as a policy setting. MinSwapAmountMsat uint64 `json:"min_swap_amount_msat"` // AllowNewSwaps can be used to disallow any new swaps. This can be useful // when we want to upgrade the node and do not want to allow for any new // swap request from the peer or the node operator. AllowNewSwaps bool `json:"allow_new_swaps" long:"allow_new_swaps" description:"If set to false, disables all swap requests, defaults to true."` // contains filtered or unexported fields }
PolicyConfig will ensure that a swap request is only performed if the policy is matched. In this case this means that the requesting peer is part of the allowlist and that the tank reserve is respected.
func CreateFromFile ¶
CreateFromFile returns a policy based on a DefaultPolicy and a ini file with a policy configuration. If the path to the policy file (ini notation) is empty, the default policy is used.
func DefaultPolicy ¶
func DefaultPolicy() *Policy
DefaultPolicy returns a policy struct made from the default values.
func (*Policy) AddToAllowlist ¶
AddToAllowlist adds a peer to the policy file in runtime. The pubkey is expected to be hex encoded.
func (*Policy) AddToSuspiciousPeerList ¶
AddToSuspiciousPeerList adds a peer as a suspicious peer to the policy file in runtime. The pubkey is expected to be hex encoded.
func (*Policy) DisableSwaps ¶
DisableSwaps sets the AllowNewSwaps field to false. This persists in the policy.conf.
func (*Policy) EnableSwaps ¶
EnableSwaps sets the AllowNewSwaps field to true. This persists in the policy.conf.
func (*Policy) GetMinSwapAmountMsat ¶
GetMinSwapAmountMsat returns the minimum swap amount in msat that is needed to perform a swap.
func (*Policy) GetReserveOnchainMsat ¶
GetReserveOnchainMsat returns the amount of msats that should be keept in the wallet when receiving a peerswap request.
func (*Policy) IsPeerAllowed ¶
IsPeerAllowed returns if a peer or node is part of the allowlist.
func (*Policy) IsPeerSuspicious ¶
IsPeerSuspicious returns true if the peer is on the list of suspicious peers.
func (*Policy) NewSwapsAllowed ¶
NewSwapsAllowed returns the boolean value of AllowNewSwaps.
func (*Policy) ReloadFile ¶
ReloadFile reloads and and sets the policy to the policy file. This might be because the policy file changed and the runtime should use the new policy.
func (*Policy) RemoveFromAllowlist ¶
RemoveFromAllowlist removes the pubkey of a node from the policy allowlisted_peers list. If a pubkey is removed from the allowlist the node corresponding to the pubkey is no longer allowed to request swaps. The pubkey is expected to be hex encoded.
func (*Policy) RemoveFromSuspiciousPeerList ¶
RemoveFromSuspiciousPeerList removes the pubkey of a node from the policy suspicious_peers list. The pubkey is expected to be hex encoded.