Release v2.2.1

This commit is contained in:
Juan Pablo Civile
2022-03-16 11:14:47 -03:00
parent 58d843ad79
commit 6425a5b0da
18 changed files with 113 additions and 89 deletions

View File

@@ -33,8 +33,8 @@ type MuunPaymentURI struct {
Label string
Message string
Amount string
URI string
BIP70Url string
Uri string
Bip70Url string
CreationTime string
ExpiresTime string
Invoice *Invoice
@@ -92,6 +92,16 @@ func GetPaymentURI(rawInput string, network *Network) (*MuunPaymentURI, error) {
}
}
// legacy Apollo P2P/contacts check
if (strings.Contains(rawInput, "contacts/")) {
return &MuunPaymentURI{
Label: label,
Message: message,
Amount: amount,
Uri: bitcoinUri,
}, nil
}
//BIP70 check
if len(queryValues["r"]) != 0 {
if len(address) > 0 {
@@ -100,16 +110,17 @@ func GetPaymentURI(rawInput string, network *Network) (*MuunPaymentURI, error) {
Label: label,
Message: message,
Amount: amount,
URI: bitcoinUri,
BIP70Url: queryValues["r"][0],
Uri: bitcoinUri,
Bip70Url: queryValues["r"][0],
}, nil
}
return &MuunPaymentURI{
Label: label,
Message: message,
Amount: amount,
URI: bitcoinUri,
BIP70Url: queryValues["r"][0],
Uri: bitcoinUri,
Bip70Url: queryValues["r"][0],
}, nil
}
@@ -128,7 +139,7 @@ func GetPaymentURI(rawInput string, network *Network) (*MuunPaymentURI, error) {
Label: label,
Message: message,
Amount: amount,
URI: bitcoinUri,
Uri: bitcoinUri,
}, nil
}
@@ -176,11 +187,13 @@ func DoPaymentRequestCall(url string, network *Network) (*MuunPaymentURI, error)
return nil, fmt.Errorf("failed to get address: %w", err)
}
amount := float64(payDetails.Outputs[0].Amount) / 100_000_000
return &MuunPaymentURI{
Address: address,
Message: payDetails.Memo,
Amount: strconv.FormatUint(payDetails.Outputs[0].Amount, 10),
BIP70Url: url,
Amount: strconv.FormatFloat(amount, 'f', -1, 64),
Bip70Url: url,
CreationTime: strconv.FormatUint(payDetails.Time, 10),
ExpiresTime: strconv.FormatUint(payDetails.Expires, 10),
}, nil
@@ -199,10 +212,7 @@ func getAddressFromScript(script []byte, network *Network) (string, error) {
}
func buildUriFromString(rawInput string, targetScheme string) (string, *url.URL) {
newUri := rawInput
newUri = strings.Replace(newUri, muunScheme, targetScheme, 1)
newUri := strings.Replace(rawInput, muunScheme, targetScheme, 1)
if !strings.HasPrefix(strings.ToLower(newUri), targetScheme) {
newUri = targetScheme + rawInput
}

View File

@@ -42,6 +42,8 @@ func Create(version int, userKey, muunKey *hdkeychain.ExtendedKey, path string,
return CreateAddressV3(userKey, muunKey, path, network)
case V4:
return CreateAddressV4(userKey, muunKey, path, network)
case V5:
return CreateAddressV5(userKey, muunKey, path, network)
default:
return nil, fmt.Errorf("unknown or unsupported version %v", version)
}

View File

@@ -8,7 +8,7 @@ func NewStringList() *StringList {
return &StringList{}
}
func newStringList(elems []string) *StringList {
func NewStringListWithElements(elems []string) *StringList {
return &StringList{elems}
}

View File

@@ -15,6 +15,7 @@ require (
github.com/miekg/dns v1.1.29 // indirect
github.com/pdfcpu/pdfcpu v0.3.11
github.com/pkg/errors v0.9.1
github.com/shopspring/decimal v1.2.0
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/mobile v0.0.0-20210220033013-bdb1ca9a1e08 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect

View File

@@ -297,6 +297,8 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=

View File

@@ -224,7 +224,7 @@ func CreateInvoice(net *Network, userKey *HDPrivateKey, routeHints *RouteHints,
iopts = append(iopts, zpay32.Features(features))
iopts = append(iopts, zpay32.CLTVExpiry(72)) // ~1/2 day
iopts = append(iopts, zpay32.Expiry(1*time.Hour))
iopts = append(iopts, zpay32.Expiry(24*time.Hour))
var paymentAddr [32]byte
copy(paymentAddr[:], dbInvoice.PaymentSecret)

View File

@@ -28,3 +28,8 @@ func Regtest() *Network {
func (n *Network) Name() string {
return n.network.Name
}
// ToParams returns the chaincfg.Params associated with this network (only available via Go code)
func (n *Network) ToParams() *chaincfg.Params {
return n.network
}