Release v0.2.0
This commit is contained in:
parent
a60e97ace6
commit
e874baf090
|
@ -1,2 +1,4 @@
|
||||||
.data
|
.data
|
||||||
|
.idea
|
||||||
|
neutrino_test
|
||||||
|
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module recovery_tool
|
module github.com/muun/recovery_tool
|
||||||
|
|
||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ require (
|
||||||
github.com/btcsuite/btcwallet v0.10.0
|
github.com/btcsuite/btcwallet v0.10.0
|
||||||
github.com/btcsuite/btcwallet/walletdb v1.1.0
|
github.com/btcsuite/btcwallet/walletdb v1.1.0
|
||||||
github.com/lightninglabs/neutrino v0.10.0
|
github.com/lightninglabs/neutrino v0.10.0
|
||||||
github.com/muun/libwallet v0.1.4
|
github.com/muun/libwallet v0.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/lightninglabs/neutrino => github.com/muun/neutrino v0.0.0-20190914162326-7082af0fa257
|
replace github.com/lightninglabs/neutrino => github.com/muun/neutrino v0.0.0-20190914162326-7082af0fa257
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -107,8 +107,8 @@ github.com/ltcsuite/ltcutil v0.0.0-20181217130922-17f3b04680b6/go.mod h1:8Vg/LTO
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8 h1:PRMAcldsl4mXKJeRNB/KVNz6TlbS6hk2Rs42PqgU3Ws=
|
github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8 h1:PRMAcldsl4mXKJeRNB/KVNz6TlbS6hk2Rs42PqgU3Ws=
|
||||||
github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
github.com/muun/libwallet v0.1.4 h1:C8cd7+xe8TzgSuOovKbwAzFIGjjZvnyYr8HtlydEm80=
|
github.com/muun/libwallet v0.2.0 h1:Y64skcAZnwuxuSmoDPDui9RQv+3fxShDMN3UiROQ7CA=
|
||||||
github.com/muun/libwallet v0.1.4/go.mod h1:eOp7//0x8kWLXWuUyRtQlJ5WN0ZIaQNhL9++LOincrM=
|
github.com/muun/libwallet v0.2.0/go.mod h1:eOp7//0x8kWLXWuUyRtQlJ5WN0ZIaQNhL9++LOincrM=
|
||||||
github.com/muun/neutrino v0.0.0-20190914162326-7082af0fa257 h1:NW17wq2gZlEFeW3/Zx3wSmqlD0wKGf7YvhpP+CNCsbE=
|
github.com/muun/neutrino v0.0.0-20190914162326-7082af0fa257 h1:NW17wq2gZlEFeW3/Zx3wSmqlD0wKGf7YvhpP+CNCsbE=
|
||||||
github.com/muun/neutrino v0.0.0-20190914162326-7082af0fa257/go.mod h1:awTrhbCWjWNH4yVwZ4IE7nZbvpQ27e7OyD+jao7wRxA=
|
github.com/muun/neutrino v0.0.0-20190914162326-7082af0fa257/go.mod h1:awTrhbCWjWNH4yVwZ4IE7nZbvpQ27e7OyD+jao7wRxA=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
|
|
@ -89,12 +89,12 @@ const (
|
||||||
muunScheme = "muun:"
|
muunScheme = "muun:"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetPaymentURI builds a MuunPaymentURI from an address and a network
|
// GetPaymentURI builds a MuunPaymentURI from text (Bitcoin Uri, Muun Uri or address) and a network
|
||||||
func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
|
||||||
Label: label,
|
Label: label,
|
||||||
Message: message,
|
Message: message,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
URI: uriAddress,
|
URI: bitcoinUri,
|
||||||
BIP70Url: queryValues["r"][0],
|
BIP70Url: queryValues["r"][0],
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
|
||||||
Label: label,
|
Label: label,
|
||||||
Message: message,
|
Message: message,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
URI: uriAddress,
|
URI: bitcoinUri,
|
||||||
BIP70Url: queryValues["r"][0],
|
BIP70Url: queryValues["r"][0],
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ func GetPaymentURI(address string, network *Network) (*MuunPaymentURI, error) {
|
||||||
Label: label,
|
Label: label,
|
||||||
Message: message,
|
Message: message,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
URI: uriAddress,
|
URI: bitcoinUri,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -244,14 +244,14 @@ func getAddressFromScript(script []byte, network *Network) (string, error) {
|
||||||
return address.String(), nil
|
return address.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeAddress(rawAddress string) string {
|
func buildUriFromString(rawInput string) string {
|
||||||
newAddress := rawAddress
|
newUri := rawInput
|
||||||
|
|
||||||
newAddress = strings.Replace(newAddress, muunScheme, bitcoinScheme, 1)
|
newUri = strings.Replace(newUri, muunScheme, bitcoinScheme, 1)
|
||||||
|
|
||||||
if !strings.Contains(newAddress, bitcoinScheme) {
|
if !strings.Contains(newUri, bitcoinScheme) {
|
||||||
newAddress = bitcoinScheme + rawAddress
|
newUri = bitcoinScheme + rawInput
|
||||||
}
|
}
|
||||||
|
|
||||||
return newAddress
|
return newUri
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,9 +99,9 @@ func (k *ChallengePrivateKey) DecryptKey(encryptedKey string, network *Network)
|
||||||
|
|
||||||
iv := rawPubEph[len(rawPubEph)-aes.BlockSize:]
|
iv := rawPubEph[len(rawPubEph)-aes.BlockSize:]
|
||||||
|
|
||||||
block, err := aes.NewCipher(sharedSecret.Bytes())
|
block, err := aes.NewCipher(paddedSerializeBigInt(32, sharedSecret))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrapf(err, "challenge_key: failed to generate encryption key")
|
||||||
}
|
}
|
||||||
|
|
||||||
plaintext := make([]byte, len(ciphertext))
|
plaintext := make([]byte, len(ciphertext))
|
||||||
|
|
|
@ -51,9 +51,9 @@ func (k *ChallengePublicKey) EncryptKey(privKey *HDPrivateKey, recoveryCodeSalt
|
||||||
serializedPubkey := privEph.PubKey().SerializeCompressed()
|
serializedPubkey := privEph.PubKey().SerializeCompressed()
|
||||||
iv := serializedPubkey[len(serializedPubkey)-aes.BlockSize:]
|
iv := serializedPubkey[len(serializedPubkey)-aes.BlockSize:]
|
||||||
|
|
||||||
block, err := aes.NewCipher(sharedSecret.Bytes())
|
block, err := aes.NewCipher(paddedSerializeBigInt(32, sharedSecret))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.Wrapf(err, "challenge_public_key: failed to generate encryption key")
|
||||||
}
|
}
|
||||||
|
|
||||||
ciphertext := make([]byte, len(plaintext))
|
ciphertext := make([]byte, len(plaintext))
|
||||||
|
|
|
@ -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...)
|
||||||
|
}
|
|
@ -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 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/queue v1.0.1/go.mod h1:vaQwexir73flPW43Mrm7JOgJHmcEFBWWSl9HlyASoms=
|
||||||
github.com/lightningnetwork/lnd/ticker v1.0.0/go.mod h1:iaLXJiVgI1sPANIF2qYYUJXjoksPNvGNYowB8aRbpX0=
|
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/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/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=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
|
|
@ -15,7 +15,7 @@ type Invoice struct {
|
||||||
Network *Network
|
Network *Network
|
||||||
MilliSat string
|
MilliSat string
|
||||||
Destination []byte
|
Destination []byte
|
||||||
PaymentHash [32]byte
|
PaymentHash []byte
|
||||||
Expiry int64
|
Expiry int64
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func ParseInvoice(invoice string, network *Network) (*Invoice, error) {
|
||||||
Network: network,
|
Network: network,
|
||||||
MilliSat: milliSats,
|
MilliSat: milliSats,
|
||||||
Destination: parsedInvoice.Destination.SerializeCompressed(),
|
Destination: parsedInvoice.Destination.SerializeCompressed(),
|
||||||
PaymentHash: *parsedInvoice.PaymentHash,
|
PaymentHash: parsedInvoice.PaymentHash[:],
|
||||||
Expiry: parsedInvoice.Timestamp.Unix() + int64(parsedInvoice.Expiry().Seconds()),
|
Expiry: parsedInvoice.Timestamp.Unix() + int64(parsedInvoice.Expiry().Seconds()),
|
||||||
Description: description,
|
Description: description,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -71,7 +71,7 @@ github.com/lightningnetwork/lnd/ticker
|
||||||
# github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8
|
# github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8
|
||||||
github.com/miekg/dns
|
github.com/miekg/dns
|
||||||
github.com/miekg/dns/internal/socket
|
github.com/miekg/dns/internal/socket
|
||||||
# github.com/muun/libwallet v0.1.4
|
# github.com/muun/libwallet v0.2.0
|
||||||
github.com/muun/libwallet
|
github.com/muun/libwallet
|
||||||
# github.com/pkg/errors v0.8.1
|
# github.com/pkg/errors v0.8.1
|
||||||
github.com/pkg/errors
|
github.com/pkg/errors
|
||||||
|
|
Loading…
Reference in New Issue