diff --git a/Makefile b/Makefile index c5803dd..877a9de 100644 --- a/Makefile +++ b/Makefile @@ -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)/ @@ -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* diff --git a/bria/client.go b/bria/client.go index e334c8c..25d71e8 100644 --- a/bria/client.go +++ b/bria/client.go @@ -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 diff --git a/docs/resources/payout_queue.md b/docs/resources/payout_queue.md index 08441ed..fc1457a 100644 --- a/docs/resources/payout_queue.md +++ b/docs/resources/payout_queue.md @@ -37,4 +37,8 @@ Required: - `interval_secs` (Number) - `tx_priority` (String) +Optional: + +- `cpfp_payouts_after_mins` (Number) + diff --git a/example/main.tf b/example/main.tf index 8ee6096..7d06477 100644 --- a/example/main.tf +++ b/example/main.tf @@ -6,7 +6,7 @@ terraform { } bria = { source = "galoymoney/bria" - version = "0.0.10" + version = "0.0.11" } } } @@ -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 } } - diff --git a/provider/payout_queue.go b/provider/payout_queue.go index c6ca15e..0d1098c 100644 --- a/provider/payout_queue.go +++ b/provider/payout_queue.go @@ -42,6 +42,11 @@ func resourcePayoutQueue() *schema.Resource { Type: schema.TypeInt, Required: true, }, + "cpfp_payouts_after_mins": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, }, }, }, @@ -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) @@ -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) } @@ -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)