Skip to content

Commit

Permalink
updating p4 paymentRequest response to support new format with Destin…
Browse files Browse the repository at this point in the history
…ations and plural fees. Re-vendoring (#53)
  • Loading branch information
theflyingcodr authored Oct 1, 2021
1 parent ad50111 commit a05e195
Show file tree
Hide file tree
Showing 77 changed files with 59 additions and 3,010 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cover.out
wallet.db
main
docker-compose.dev.yml
docker-compose.override.yml
cover.out
cover.html

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ run-compose-d:
run-compose-dev:
@docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

run-compose-testnet:
@docker-compose -f docker-compose.yml -f docker-compose.testnet.yml up

build-image:
@docker-compose -f docker-compose.yml -f docker-compose.build.yml build

Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,12 @@ github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/libsv/go-bc v0.1.4 h1:p1ZT5OvXBDdKSgZaRwXd0JCrGuJ44gp05DiqUSCMdP8=
github.com/libsv/go-bc v0.1.4/go.mod h1:rrlTAokCx10eCQnutt6g++LqTQ+I1n+SPCwKDVK4sd8=
github.com/libsv/go-bc v0.1.5-0.20210929125350-a1fa4c6f5404 h1:vm0W01SdS4dpv2dRJGy/if0AudeS+VDrTX+nthzPjhQ=
github.com/libsv/go-bc v0.1.5-0.20210929125350-a1fa4c6f5404/go.mod h1:IZuBIf65nlLY1OR/oXGOW/AgVvO5hGhIhRZPiHAiVHU=
github.com/libsv/go-bc v0.1.5-0.20210929134219-ae16368dc22c h1:do7BgyzVmkRifffwfPMJyRPEinyAEwxZID41c84O7xo=
github.com/libsv/go-bc v0.1.5-0.20210929134219-ae16368dc22c/go.mod h1:IZuBIf65nlLY1OR/oXGOW/AgVvO5hGhIhRZPiHAiVHU=
github.com/libsv/go-bc v0.1.5 h1:PVgJbyT+BAkKexInOrXmUf8MW+69+t7YEUH4/c1eqXg=
github.com/libsv/go-bc v0.1.5/go.mod h1:rrlTAokCx10eCQnutt6g++LqTQ+I1n+SPCwKDVK4sd8=
github.com/libsv/go-bc v0.1.6 h1:jacgv/22R5TI1u3PInc7EG7TcvbdQWO2y3mA8be4v1w=
github.com/libsv/go-bc v0.1.6/go.mod h1:IZuBIf65nlLY1OR/oXGOW/AgVvO5hGhIhRZPiHAiVHU=
github.com/libsv/go-bk v0.0.0-20210430094342-ff08e691962b/go.mod h1:xbDkeFFpP0uyFaPLnP6TwaLpAsHaslZ0LftTdWlB6HI=
github.com/libsv/go-bk v0.1.4 h1:bTxlerGeibh8RRmyhFK03wSAEp6EAJxGR4vXuRT0LCE=
github.com/libsv/go-bk v0.1.4/go.mod h1:xbDkeFFpP0uyFaPLnP6TwaLpAsHaslZ0LftTdWlB6HI=
github.com/libsv/go-bt v1.0.1 h1:47Z50nVjEUbgt+zSTKEHf4JMKDeFDAJbrSEheqKC90w=
github.com/libsv/go-bt v1.0.1/go.mod h1:AfXoLFYEbY/TvCq/84xTce2xGjPUuC5imokHmcykF2k=
github.com/libsv/go-bt/v2 v2.0.0-20210730150403-97fd3b293e05/go.mod h1:62PATaSIMQ3omXVr9D4S7uMKaQByCJjNkrNzFpYThco=
github.com/libsv/go-bt/v2 v2.0.0-beta.7 h1:ccJXfmO2i+79oP/mDYYqvqa5DH1QV+2a1eh8+HUKhic=
github.com/libsv/go-bt/v2 v2.0.0-beta.7/go.mod h1:6Vk1qMlMoFJFNm7rR7NmFx4VwHNMCi4+V9WBqTd37rQ=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
Expand Down
19 changes: 12 additions & 7 deletions pay.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ type P4Output struct {
Description string `json:"description"`
}

// P4Destination defines a P4 payment destination object.
type P4Destination struct {
Outputs []P4Output `json:"outputs"`
}

// PaymentRequestResponse a payment request from p4.
type PaymentRequestResponse struct {
Network string `json:"network"`
Outputs []P4Output `json:"outputs"`
CreationTimestamp time.Time `json:"creationTimestamp"`
ExpirationTimestamp time.Time `json:"expirationTimestamp"`
PaymentURL string `json:"paymentURL"`
Memo string `json:"memo"`
Network string `json:"network"`
Destinations P4Destination `json:"destinations"`
CreationTimestamp time.Time `json:"creationTimestamp"`
ExpirationTimestamp time.Time `json:"expirationTimestamp"`
PaymentURL string `json:"paymentURL"`
Memo string `json:"memo"`
MerchantData struct {
Avatar string `json:"avatar"`
Name string `json:"name"`
Expand All @@ -45,7 +50,7 @@ type PaymentRequestResponse struct {
PaymentReference string `json:"paymentReference"`
ExtendedData map[string]string `json:"extendedData"`
} `json:"merchantData"`
Fee *bt.FeeQuote `json:"fee"`
Fee *bt.FeeQuote `json:"fees"`
}

// PaymentACK an ack response from P4.
Expand Down
2 changes: 1 addition & 1 deletion service/pay.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (p *pay) Pay(ctx context.Context, req payd.PayRequest) (*payd.PaymentACK, e

tx := bt.NewTx()
// Add funds to new tx.
for _, out := range payReq.Outputs {
for _, out := range payReq.Destinations.Outputs {
lockingScript, err := bscript.NewFromHexString(out.Script)
if err != nil {
return nil, errors.Wrapf(err, "failed to parsed script %s", out.Script)
Expand Down
1 change: 0 additions & 1 deletion service/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (p *payments) PaymentCreate(ctx context.Context, req payd.PaymentCreate) er
if inv.State != payd.StateInvoicePending {
return lathos.NewErrDuplicate("D001", fmt.Sprintf("payment already received for invoice ID '%s'", req.InvoiceID))
}

fq, err := p.feeRdr.Fees(ctx)
if err != nil {
return errors.Wrapf(err, "failed to read fees for payment with id %s", req.InvoiceID)
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/boombuler/barcode/go.mod

This file was deleted.

7 changes: 0 additions & 7 deletions vendor/github.com/fsnotify/fsnotify/go.mod

This file was deleted.

2 changes: 0 additions & 2 deletions vendor/github.com/fsnotify/fsnotify/go.sum

This file was deleted.

9 changes: 0 additions & 9 deletions vendor/github.com/go-openapi/jsonpointer/go.mod

This file was deleted.

24 changes: 0 additions & 24 deletions vendor/github.com/go-openapi/jsonpointer/go.sum

This file was deleted.

11 changes: 0 additions & 11 deletions vendor/github.com/go-openapi/jsonreference/go.mod

This file was deleted.

37 changes: 0 additions & 37 deletions vendor/github.com/go-openapi/jsonreference/go.sum

This file was deleted.

13 changes: 0 additions & 13 deletions vendor/github.com/go-openapi/spec/go.mod

This file was deleted.

65 changes: 0 additions & 65 deletions vendor/github.com/go-openapi/spec/go.sum

This file was deleted.

18 changes: 0 additions & 18 deletions vendor/github.com/go-openapi/swag/go.mod

This file was deleted.

Loading

0 comments on commit a05e195

Please sign in to comment.