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:
Jim Posen authored and Olaoluwa Osuntokun committed 2018-01-31 14:30:56 -08:00
1 parent 94b10c6c06
commit 916b83a6ee
4 files changed
+1022 -97

No files matched your search

-30
View File
@@ -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())
}