remotesigning

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Overview

Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateWitnessHash added in v0.13.0

func CalculateWitnessHash(amount int64, script string, transaction string) (*string, error)

func CalculateWitnessHashPSBT added in v0.13.0

func CalculateWitnessHashPSBT(transaction string) (*string, error)

func DeclineToSignMessages

func DeclineToSignMessages(client *services.LightsparkClient, event webhooks.WebhookEvent) (string, error)

func DerivationPathFromString added in v0.16.0

func DerivationPathFromString(path string) ([]uint32, error)

func DeriveKey added in v0.16.0

func DeriveKey(masterSeed []byte, derivationPath []uint32, networkParams *chaincfg.Params) (*hdkeychain.ExtendedKey, error)

func DeriveL1WalletHardenedXpub added in v0.16.0

func DeriveL1WalletHardenedXpub(masterSeed []byte, networkParams *chaincfg.Params) (*hdkeychain.ExtendedKey, error)

func DerivePublicKey added in v0.16.0

func DerivePublicKey(masterSeed []byte, derivationPath string, networkParams *chaincfg.Params) (*secp256k1.PublicKey, error)

func GenerateP2WPKHFromPubkey added in v0.16.0

func GenerateP2WPKHFromPubkey(child_pubkey []byte) ([]byte, error)

func GetPaymentHashFromScript added in v0.7.0

func GetPaymentHashFromScript(scriptHex string) (*string, error)

func HandleRemoteSigningWebhook

func HandleRemoteSigningWebhook(
	client *services.LightsparkClient,
	validator Validator,
	webhook webhooks.WebhookEvent,
	seedBytes []byte,
) (string, error)

HandleRemoteSigningWebhook handles a webhook event that is related to remote signing.

This method should only be called with a webhook event that has the event_type `WebhookEventTypeRemoteSigning`. The method will call the appropriate handler for the sub_event_type of the webhook.

Args:

	client: The LightsparkClient used to respond to webhook events.
    validator: A validator for deciding whether to sign events.
	webhook: The webhook event that you want to handle.
	seedBytes: The bytes of the master seed that you want to use to sign messages or derive keys.

func HandleSigningResponse added in v0.5.0

func HandleSigningResponse(client *services.LightsparkClient, response SigningResponse) (string, error)

func L1WalletDerivationPrefix added in v0.16.0

func L1WalletDerivationPrefix(networkParams *chaincfg.Params) (string, error)

func ValidateChangeScript added in v0.16.0

func ValidateChangeScript(tx wire.MsgTx, expectedScript []byte) (bool, error)

func ValidateOutputScript added in v0.16.0

func ValidateOutputScript(tx wire.MsgTx, expectedScript []byte) (bool, error)

func ValidateWitnessHash added in v0.16.0

func ValidateWitnessHash(signing *SigningJob) bool

Types

type DeriveKeyAndSignRequest added in v0.5.0

type DeriveKeyAndSignRequest struct {
	SigningJobs    []SigningJob
	BitcoinNetwork objects.BitcoinNetwork
}

A signing request asking for a key to be derived and used to sign a message.

func ParseDeriveAndSignRequest added in v0.5.0

func ParseDeriveAndSignRequest(webhook webhooks.WebhookEvent) (*DeriveKeyAndSignRequest, error)

func (*DeriveKeyAndSignRequest) Type added in v0.5.0

type DeriveKeyAndSignResponse added in v0.5.0

type DeriveKeyAndSignResponse struct {
	Signatures []SignatureResponse
}

func HandleDeriveKeyAndSignRequest added in v0.5.0

func HandleDeriveKeyAndSignRequest(request *DeriveKeyAndSignRequest, seedBytes []byte) (*DeriveKeyAndSignResponse, error)

func (DeriveKeyAndSignResponse) GraphqlResponse added in v0.5.0

func (r DeriveKeyAndSignResponse) GraphqlResponse() *GraphQLResponse

type DestinationValidator added in v0.16.0

type DestinationValidator struct {
	// contains filtered or unexported fields
}

A validator that checks that the outputs of a transaction pass restrictions for where we allow sending funds. This is used to ensure that when signing transactions spending L1 wallet funds, we are only sending funds to certain addresses.

func NewDestinationValidator added in v0.16.0

func NewDestinationValidator(masterSeed []byte, validateForceClosureClaims bool) DestinationValidator

func (DestinationValidator) ShouldSign added in v0.16.0

func (v DestinationValidator) ShouldSign(webhookEvent webhooks.WebhookEvent) bool

type ECDHRequest added in v0.5.0

type ECDHRequest struct {
	NodeId         string
	PeerPubKeyHex  string
	BitcoinNetwork objects.BitcoinNetwork
}

A signing request asking for a shared secret to be computed using Eliptic Curve Diffie-Hellman. The shared secret is computed using your node's identity private key and the peer's public key. This request is only for nodes created before 10/06/2023.

func ParseECDHRequest added in v0.5.0

func ParseECDHRequest(webhook webhooks.WebhookEvent) (*ECDHRequest, error)

func (*ECDHRequest) Type added in v0.5.0

type ECDHResponse added in v0.5.0

type ECDHResponse struct {
	NodeId          string
	SharedSecretHex string
}

func HandleEcdhRequest added in v0.5.0

func HandleEcdhRequest(request *ECDHRequest, seedBytes []byte) (*ECDHResponse, error)

func (ECDHResponse) GraphqlResponse added in v0.5.0

func (r ECDHResponse) GraphqlResponse() *GraphQLResponse

type GetPerCommitmentPointRequest added in v0.5.0

type GetPerCommitmentPointRequest struct {
	ChannelId             string
	DerivationPath        string
	PerCommitmentPointIdx uint64
	NodeId                string
	BitcoinNetwork        objects.BitcoinNetwork
}

A signing request asking for a per-commitment point for a particular channel. The per-commitment point is the point on the secp256k1 curve for the commitment secret described in bolt 3.

func ParseGetPerCommitmentPointRequest added in v0.5.0

func ParseGetPerCommitmentPointRequest(webhook webhooks.WebhookEvent) (*GetPerCommitmentPointRequest, error)

func (*GetPerCommitmentPointRequest) Type added in v0.5.0

type GetPerCommitmentPointResponse added in v0.5.0

type GetPerCommitmentPointResponse struct {
	ChannelId             string
	PerCommitmentPointIdx uint64
	PerCommitmentPointHex string
}

func HandleGetPerCommitmentPointRequest added in v0.5.0

func HandleGetPerCommitmentPointRequest(request *GetPerCommitmentPointRequest, seedBytes []byte) (*GetPerCommitmentPointResponse, error)

func (GetPerCommitmentPointResponse) GraphqlResponse added in v0.5.0

func (r GetPerCommitmentPointResponse) GraphqlResponse() *GraphQLResponse

type GraphQLResponse added in v0.5.0

type GraphQLResponse struct {
	Query       string
	Variables   map[string]interface{}
	OutputField string
}

type HashValidator added in v0.13.0

type HashValidator struct{}

func (HashValidator) ShouldSign added in v0.13.0

func (v HashValidator) ShouldSign(webhookEvent webhooks.WebhookEvent) bool

type InvoicePaymentHashRequest added in v0.5.0

type InvoicePaymentHashRequest struct {
	InvoiceId      string
	BitcoinNetwork objects.BitcoinNetwork
}

A signing request asking for a payment hash. A payment hash is the hash of a payment preimage. The payment preimage is the secret that is revealed when a payment is made on the Lightning Network.

func ParseRequestInvoicePaymentHashRequest added in v0.5.0

func ParseRequestInvoicePaymentHashRequest(webhook webhooks.WebhookEvent) (*InvoicePaymentHashRequest, error)

func (*InvoicePaymentHashRequest) Type added in v0.5.0

type InvoicePaymentHashResponse added in v0.5.0

type InvoicePaymentHashResponse struct {
	InvoiceId      string
	PaymentHashHex string
	Nonce          *string
}

func HandleInvoicePaymentHashRequest added in v0.5.0

func HandleInvoicePaymentHashRequest(request *InvoicePaymentHashRequest, seedBytes []byte) (*InvoicePaymentHashResponse, error)

func (InvoicePaymentHashResponse) GraphqlResponse added in v0.5.0

func (r InvoicePaymentHashResponse) GraphqlResponse() *GraphQLResponse

type MultiValidator added in v0.16.0

type MultiValidator struct {
	// contains filtered or unexported fields
}

func NewMultiValidator added in v0.16.0

func NewMultiValidator(validators ...Validator) MultiValidator

func (MultiValidator) ShouldSign added in v0.16.0

func (v MultiValidator) ShouldSign(webhookEvent webhooks.WebhookEvent) bool

type PositiveValidator

type PositiveValidator struct{}

func (PositiveValidator) ShouldSign

func (v PositiveValidator) ShouldSign(webhook webhooks.WebhookEvent) bool

type ReleaseCounterpartyPerCommitmentSecretRequest added in v0.5.0

type ReleaseCounterpartyPerCommitmentSecretRequest struct {
	ChannelId              string
	PerCommitmentSecretIdx uint64
	PerCommitmentSecret    string
	NodeId                 string
}

A informational request that reveals counterparty per-commitment secret.

func ParseReleaseCounterpartyPerCommitmentSecretRequest added in v0.5.0

func ParseReleaseCounterpartyPerCommitmentSecretRequest(webhook webhooks.WebhookEvent) (*ReleaseCounterpartyPerCommitmentSecretRequest, error)

func (*ReleaseCounterpartyPerCommitmentSecretRequest) Type added in v0.5.0

type ReleasePaymentPreimageRequest added in v0.5.0

type ReleasePaymentPreimageRequest struct {
	InvoiceId      string
	Nonce          *string
	BitcoinNetwork objects.BitcoinNetwork
	IsUma          bool
	IsLnurl        bool
}

A signing request asking for a payment preimage to be released.

func ParseReleasePaymentPreimageRequest added in v0.5.0

func ParseReleasePaymentPreimageRequest(webhook webhooks.WebhookEvent) (*ReleasePaymentPreimageRequest, error)

func (*ReleasePaymentPreimageRequest) Type added in v0.5.0

type ReleasePaymentPreimageResponse added in v0.5.0

type ReleasePaymentPreimageResponse struct {
	InvoiceId       string
	PaymentPreimage string
}

func HandleReleaseInvoicePreimageRequest added in v0.5.0

func HandleReleaseInvoicePreimageRequest(request *ReleasePaymentPreimageRequest, seedBytes []byte) (*ReleasePaymentPreimageResponse, error)

func (ReleasePaymentPreimageResponse) GraphqlResponse added in v0.5.0

func (r ReleasePaymentPreimageResponse) GraphqlResponse() *GraphQLResponse

type ReleasePerCommitmentSecretRequest added in v0.5.0

type ReleasePerCommitmentSecretRequest struct {
	ChannelId             string
	DerivationPath        string
	PerCommitmentPointIdx uint64
	NodeId                string
	BitcoinNetwork        objects.BitcoinNetwork
}

A signing request asking for a per-commitment secret to be released for a particular channel. The per-commitment secret is the secret described in bolt 3.

func ParseReleasePerCommitmentSecretRequest added in v0.5.0

func ParseReleasePerCommitmentSecretRequest(webhook webhooks.WebhookEvent) (*ReleasePerCommitmentSecretRequest, error)

func (*ReleasePerCommitmentSecretRequest) Type added in v0.5.0

type ReleasePerCommitmentSecretResponse added in v0.5.0

type ReleasePerCommitmentSecretResponse struct {
	ChannelId             string
	PerCommitmentPointIdx uint64
	PerCommitmentSecret   string
}

func HandleReleasePerCommitmentSecretRequest added in v0.5.0

func HandleReleasePerCommitmentSecretRequest(request *ReleasePerCommitmentSecretRequest, seedBytes []byte) (*ReleasePerCommitmentSecretResponse, error)

func (ReleasePerCommitmentSecretResponse) GraphqlResponse added in v0.5.0

type SignInvoiceRequest added in v0.5.0

type SignInvoiceRequest struct {
	InvoiceId          string
	PaymentRequestHash string
	BitcoinNetwork     objects.BitcoinNetwork
}

A signing request asking for an invoice to be signed. The invoice is signed using the node's identity private key. This request is only for nodes created before 10/06/2023.

func ParseSignInvoiceRequest added in v0.5.0

func ParseSignInvoiceRequest(webhook webhooks.WebhookEvent) (*SignInvoiceRequest, error)

func (*SignInvoiceRequest) Type added in v0.5.0

type SignInvoiceResponse added in v0.5.0

type SignInvoiceResponse struct {
	InvoiceId  string
	Signature  string
	RecoveryId int32
}

func HandleSignInvoiceRequest added in v0.5.0

func HandleSignInvoiceRequest(request *SignInvoiceRequest, seedBytes []byte) (*SignInvoiceResponse, error)

func (SignInvoiceResponse) GraphqlResponse added in v0.5.0

func (r SignInvoiceResponse) GraphqlResponse() *GraphQLResponse

type SignatureResponse added in v0.5.0

type SignatureResponse struct {
	Id        string `json:"id"`
	Signature string `json:"signature"`
}

SignatureResponse A separate type is required for the response because the json field names are different from objects.Signature.

type SigningJob

type SigningJob struct {
	Id                        string  `json:"id"`
	DerivationPath            string  `json:"derivation_path"`
	Message                   string  `json:"message"`
	AddTweak                  *string `json:"add_tweak"`
	MulTweak                  *string `json:"mul_tweak"`
	Script                    *string `json:"script"`
	Transaction               *string `json:"transaction"`
	Amount                    *int64  `json:"amount"`
	DestinationDerivationPath string  `json:"destination_derivation_path"`
}

A signing job is a request to sign a message with a particular key. The signig key is computed using the node's master key and the parameter. DerivationPath is the bip32 derivation path to get the key from the master key `k`. Then apply MulTweak * k + AddTweak to get the final signing key.

func (*SigningJob) AddTweakBytes

func (j *SigningJob) AddTweakBytes() ([]byte, error)

func (*SigningJob) BitcoinTx added in v0.16.0

func (j *SigningJob) BitcoinTx() (wire.MsgTx, error)

func (*SigningJob) MessageBytes

func (j *SigningJob) MessageBytes() ([]byte, error)

func (*SigningJob) MulTweakBytes

func (j *SigningJob) MulTweakBytes() ([]byte, error)

type SigningRequest added in v0.5.0

type SigningRequest interface {
	Type() objects.RemoteSigningSubEventType
}

func ParseRemoteSigningRequest added in v0.5.0

func ParseRemoteSigningRequest(webhook webhooks.WebhookEvent) (SigningRequest, error)

type SigningResponse added in v0.5.0

type SigningResponse interface {
	GraphqlResponse() *GraphQLResponse
}

func GraphQLResponseForRemoteSigningWebhook added in v0.12.0

func GraphQLResponseForRemoteSigningWebhook(
	validator Validator,
	webhook webhooks.WebhookEvent,
	seedBytes []byte,
) (SigningResponse, error)

func HandleSigningRequest added in v0.5.0

func HandleSigningRequest(request SigningRequest, seedBytes []byte) (SigningResponse, error)

type Validator

type Validator interface {
	ShouldSign(webhook webhooks.WebhookEvent) bool
}

Validator an interface which decides whether to sign or reject a remote signing webhook event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL