Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
keithsue committed Jan 12, 2025
1 parent 0b89079 commit 51de731
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions x/lending/types/taproot.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript"

"github.com/sideprotocol/side/crypto/adaptor"
"github.com/sideprotocol/side/crypto/hash"
"github.com/sideprotocol/side/x/dlc/types"
)

// HashLoanSecret hashes the given secret
// Assume that the secret is a valid hex string
func HashLoanSecret(secret string) string {
// Todo later
return secret
secretBytes, _ := hex.DecodeString(secret)

return hex.EncodeToString(hash.Sha256(secretBytes))
}

// AdaptorPoint gets the corresponding adaptor point from the given secret
// Assume that the secret is a valid hex string
func AdaptorPoint(secret string) string {
return secret
secretBytes, _ := hex.DecodeString(secret)

return hex.EncodeToString(adaptor.SecretToPubKey(secretBytes))
}

func GetTaprootAddress(script []byte) (*btcutil.AddressTaproot, error) {
Expand Down

0 comments on commit 51de731

Please # to comment.