Skip to content

Commit

Permalink
feat: add support for cpfp_payouts_after_mins to bria_payout_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Nov 24, 2023
1 parent db90632 commit 54de1fc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ HOSTNAME=galoymoney
PROTO_DIR := proto/vendor
PROTO_OUTPUT_DIR := bria/proto

version = 0.0.10
version = 0.0.11
os_arch = $(shell go env GOOS)_$(shell go env GOARCH)
provider_path = registry.terraform.io/galoymoney/bria/$(version)/$(os_arch)/

Expand All @@ -32,7 +32,7 @@ gen-docs:
build:
go build -o $(BINARY) main.go

install: gen-proto build
install: gen-proto build
mkdir -p ~/.terraform.d/plugins/${provider_path}
mv ${BINARY} ~/.terraform.d/plugins/${provider_path}
rm -rf example/.terraform example/.terraform.lock.hcl example/terraform.tfstate*
Expand Down
1 change: 1 addition & 0 deletions bria/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func (c *AccountClient) CreatePayoutQueue(name string, description string, confi
Config: config,
}
ctx := context.Background()

res, err := c.service.CreatePayoutQueue(ctx, req)
if err != nil {
return nil, err
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/payout_queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ Required:
- `interval_secs` (Number)
- `tx_priority` (String)

Optional:

- `cpfp_payouts_after_mins` (Number)


4 changes: 2 additions & 2 deletions example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
bria = {
source = "galoymoney/bria"
version = "0.0.10"
version = "0.0.11"
}
}
}
Expand Down Expand Up @@ -114,6 +114,6 @@ resource "bria_payout_queue" "interval" {
tx_priority = "NEXT_BLOCK"
consolidate_deprecated_keychains = true
interval_secs = 3600
cpfp_payouts_after_mins = 5
}
}

25 changes: 25 additions & 0 deletions provider/payout_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func resourcePayoutQueue() *schema.Resource {
Type: schema.TypeInt,
Required: true,
},
"cpfp_payouts_after_mins": {
Type: schema.TypeInt,
Optional: true,
Default: -1,
},
},
},
},
Expand All @@ -63,6 +68,13 @@ func resourcePayoutQueueCreate(d *schema.ResourceData, m interface{}) error {

config.Trigger = &briav1.PayoutQueueConfig_IntervalSecs{IntervalSecs: uint32(configData["interval_secs"].(int))}

if val, ok := configData["cpfp_payouts_after_mins"]; ok {
if val.(int) >= 0 {
tempVal := uint32(val.(int))
config.CpfpPayoutsAfterMins = &tempVal
}
}

res, err := client.CreatePayoutQueue(name, description, config)
if err != nil {
return fmt.Errorf("error creating Bria batch group: %w", err)
Expand Down Expand Up @@ -103,6 +115,12 @@ func resourcePayoutQueueRead(d *schema.ResourceData, meta interface{}) error {
config["interval_secs"] = intervalSecs.IntervalSecs
}

if queue.Config.CpfpPayoutsAfterMins != nil {
config["cpfp_payouts_after_mins"] = *queue.Config.CpfpPayoutsAfterMins
} else {
config["cpfp_payouts_after_mins"] = -1
}

if err := d.Set("config", []interface{}{config}); err != nil {
return fmt.Errorf("error setting config: %w", err)
}
Expand All @@ -125,6 +143,13 @@ func resourcePayoutQueueUpdate(d *schema.ResourceData, m interface{}) error {

config.Trigger = &briav1.PayoutQueueConfig_IntervalSecs{IntervalSecs: uint32(configData["interval_secs"].(int))}

if val, ok := configData["cpfp_payouts_after_mins"]; ok {
if val.(int) >= 0 {
tempVal := uint32(val.(int))
config.CpfpPayoutsAfterMins = &tempVal
}
}

_, err := client.UpdatePayoutQueue(queueId, description, config)
if err != nil {
return fmt.Errorf("error updating Bria payout queue: %w", err)
Expand Down

0 comments on commit 54de1fc

Please sign in to comment.