Release v0.2.0

This commit is contained in:
Juan Pablo Civile
2019-12-17 17:32:12 -03:00
parent a60e97ace6
commit e874baf090
10 changed files with 43 additions and 24 deletions

View File

@@ -89,12 +89,12 @@ const (
muunScheme = "muun:"
)
// GetPaymentURI builds a MuunPaymentURI from an address and a network
func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
// GetPaymentURI builds a MuunPaymentURI from text (Bitcoin Uri, Muun Uri or address) and a network
func GetPaymentURI(rawInput string, network *Network) (*MuunPaymentURI, error) {
uriAddress := normalizeAddress(address)
bitcoinUri := buildUriFromString(rawInput)
components, err := url.Parse(uriAddress)
components, err := url.Parse(bitcoinUri)
if err != nil {
return nil, err
}
@@ -146,7 +146,7 @@ func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
Label: label,
Message: message,
Amount: amount,
URI: uriAddress,
URI: bitcoinUri,
BIP70Url: queryValues["r"][0],
}, nil
}
@@ -154,7 +154,7 @@ func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
Label: label,
Message: message,
Amount: amount,
URI: uriAddress,
URI: bitcoinUri,
BIP70Url: queryValues["r"][0],
}, nil
}
@@ -174,7 +174,7 @@ func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
Label: label,
Message: message,
Amount: amount,
URI: uriAddress,
URI: bitcoinUri,
}, nil
}
@@ -244,14 +244,14 @@ func getAddressFromScript(script []byte, network *Network) (string, error) {
return address.String(), nil
}
func normalizeAddress(rawAddress string) string {
newAddress := rawAddress
func buildUriFromString(rawInput string) string {
newUri := rawInput
newAddress = strings.Replace(newAddress, muunScheme, bitcoinScheme, 1)
newUri = strings.Replace(newUri, muunScheme, bitcoinScheme, 1)
if !strings.Contains(newAddress, bitcoinScheme) {
newAddress = bitcoinScheme + rawAddress
if !strings.Contains(newUri, bitcoinScheme) {
newUri = bitcoinScheme + rawInput
}
return newAddress
return newUri
}

View File

@@ -99,9 +99,9 @@ func (k *ChallengePrivateKey) DecryptKey(encryptedKey string, network *Network)
iv := rawPubEph[len(rawPubEph)-aes.BlockSize:]
block, err := aes.NewCipher(sharedSecret.Bytes())
block, err := aes.NewCipher(paddedSerializeBigInt(32, sharedSecret))
if err != nil {
return nil, err
return nil, errors.Wrapf(err, "challenge_key: failed to generate encryption key")
}
plaintext := make([]byte, len(ciphertext))

View File

@@ -51,9 +51,9 @@ func (k *ChallengePublicKey) EncryptKey(privKey *HDPrivateKey, recoveryCodeSalt
serializedPubkey := privEph.PubKey().SerializeCompressed()
iv := serializedPubkey[len(serializedPubkey)-aes.BlockSize:]
block, err := aes.NewCipher(sharedSecret.Bytes())
block, err := aes.NewCipher(paddedSerializeBigInt(32, sharedSecret))
if err != nil {
return "", err
return "", errors.Wrapf(err, "challenge_public_key: failed to generate encryption key")
}
ciphertext := make([]byte, len(plaintext))

16
vendor/github.com/muun/libwallet/encodings.go generated vendored Normal file
View File

@@ -0,0 +1,16 @@
package libwallet
import (
"math/big"
)
func paddedSerializeBigInt(size uint, x *big.Int) []byte {
src := x.Bytes()
dst := make([]byte, 0, size)
for i := 0; i < int(size)-len(src); i++ {
dst = append(dst, 0)
}
return append(dst, src...)
}

View File

@@ -91,6 +91,7 @@ github.com/lightningnetwork/lnd v0.8.0-beta h1:HmmhSRTq48qobqQF8YLqNa8eKU8dDBNbW
github.com/lightningnetwork/lnd v0.8.0-beta/go.mod h1:nq06y2BDv7vwWeMmwgB7P3pT7/Uj7sGf5FzHISVD6t4=
github.com/lightningnetwork/lnd/queue v1.0.1/go.mod h1:vaQwexir73flPW43Mrm7JOgJHmcEFBWWSl9HlyASoms=
github.com/lightningnetwork/lnd/ticker v1.0.0/go.mod h1:iaLXJiVgI1sPANIF2qYYUJXjoksPNvGNYowB8aRbpX0=
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw=
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796/go.mod h1:3p7ZTf9V1sNPI5H8P3NkTFF4LuwMdPl2DodF60qAKqY=
github.com/ltcsuite/ltcutil v0.0.0-20181217130922-17f3b04680b6/go.mod h1:8Vg/LTOO0KYa/vlHWJ6XZAevPQThGH5sufO0Hrou/lA=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=

View File

@@ -15,7 +15,7 @@ type Invoice struct {
Network *Network
MilliSat string
Destination []byte
PaymentHash [32]byte
PaymentHash []byte
Expiry int64
Description string
}
@@ -60,7 +60,7 @@ func ParseInvoice(invoice string, network *Network) (*Invoice, error) {
Network: network,
MilliSat: milliSats,
Destination: parsedInvoice.Destination.SerializeCompressed(),
PaymentHash: *parsedInvoice.PaymentHash,
PaymentHash: parsedInvoice.PaymentHash[:],
Expiry: parsedInvoice.Timestamp.Unix() + int64(parsedInvoice.Expiry().Seconds()),
Description: description,
}, nil