mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 03:12:54 +02:00
lnwallet: Implement test vectors from BOLT 03, Appendix C.
Appendix C of BOLT 03 contains a series of test vectors asserting that commitment, HTLC success, and HTLC timeout transactions are created correctly. Here the test cases are transcribed to Go structs and verified. We also break out some logic need to tests that bypass the constructor and remove some redundant fields.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
94b10c6c06
commit
916b83a6ee
@@ -1170,33 +1170,3 @@ func TestSpecificationKeyDerivation(t *testing.T) {
|
||||
actualRevocationPrivKeyHex)
|
||||
}
|
||||
}
|
||||
|
||||
// pubkeyFromHex parses a Bitcoin public key from a hex encoded string.
|
||||
func pubkeyFromHex(keyHex string) (*btcec.PublicKey, error) {
|
||||
bytes, err := hex.DecodeString(keyHex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return btcec.ParsePubKey(bytes, btcec.S256())
|
||||
}
|
||||
|
||||
// privkeyFromHex parses a Bitcoin private key from a hex encoded string.
|
||||
func privkeyFromHex(keyHex string) (*btcec.PrivateKey, error) {
|
||||
bytes, err := hex.DecodeString(keyHex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
key, _ := btcec.PrivKeyFromBytes(btcec.S256(), bytes)
|
||||
return key, nil
|
||||
|
||||
}
|
||||
|
||||
// pubkeyToHex serializes a Bitcoin public key to a hex encoded string.
|
||||
func pubkeyToHex(key *btcec.PublicKey) string {
|
||||
return hex.EncodeToString(key.SerializeCompressed())
|
||||
}
|
||||
|
||||
// privkeyFromHex serializes a Bitcoin private key to a hex encoded string.
|
||||
func privkeyToHex(key *btcec.PrivateKey) string {
|
||||
return hex.EncodeToString(key.Serialize())
|
||||
}
|
||||
|
Reference in New Issue
Block a user