Skip to content

Commit

Permalink
[remotesigning] Don't recognize L1 wallet signing job as PSBT (#144)
Browse files Browse the repository at this point in the history
When we added L1 wallet signing job validation, we forgot to update how
we recognize whether a signing job is for a force close claim or not.
This would mean some L1 wallet signing jobs would fail because we'd try
to calculate the sighash as if it were a PSBT, which it's not. This is
fixed here by checking the end of the derivation *plus* that it's not an
L1 wallet signing job.
  • Loading branch information
alecchendev authored Dec 16, 2024
1 parent c366102 commit 26ca018
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions remotesigning/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ func (v MultiValidator) ShouldSign(webhookEvent webhooks.WebhookEvent) bool {
return true
}

func isL1WalletSigningJob(job SigningJob) bool {
return strings.HasPrefix(job.DerivationPath, "m/84")
}

func isForceClosureClaimSigningJob(job SigningJob) bool {
return !isL1WalletSigningJob(job) &&
(strings.HasSuffix(job.DerivationPath, "/2") ||
strings.HasSuffix(job.DerivationPath, "/3"))
}

type HashValidator struct{}

func (v HashValidator) ShouldSign(webhookEvent webhooks.WebhookEvent) bool {
Expand All @@ -53,7 +63,7 @@ func (v HashValidator) ShouldSign(webhookEvent webhooks.WebhookEvent) bool {
}

func ValidateWitnessHash(signing *SigningJob) bool {
if strings.HasSuffix(signing.DerivationPath, "/2") || strings.HasSuffix(signing.DerivationPath, "/3") {
if isForceClosureClaimSigningJob(*signing) {
msg, err := CalculateWitnessHashPSBT(*signing.Transaction)
if err != nil {
return false
Expand Down Expand Up @@ -92,7 +102,7 @@ func (v DestinationValidator) ShouldSign(webhookEvent webhooks.WebhookEvent) boo
return true
}
for _, signing := range request.SigningJobs {
if strings.HasPrefix(signing.DerivationPath, "m/84") {
if isL1WalletSigningJob(signing) {
publicKey, err := DerivePublicKey(v.masterSeed, signing.DerivationPath, &chaincfg.MainNetParams)
if err != nil {
return false
Expand Down

0 comments on commit 26ca018

Please sign in to comment.