Skip to content

Commit 8e8bd84

Browse files
authored
Add ARC client compatibility: X-SkipTxValidation header, title field, response shape fixes (#36)
- Add X-SkipTxValidation header support (sets both SkipFeeValidation and SkipScriptValidation) - Add title field to TransactionStatus response - Remove omitempty from status and competingTxs fields to match ARC response shape - Add log_level to config.example.yaml
1 parent 1d8432b commit 8e8bd84

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

config.example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Environment variables can override any setting using ARCADE_ prefix
33
# Example: ARCADE_SERVER_ADDRESS=:9090 overrides server.address
44
network: main
5+
log_level: info # debug, info, warn, error
56
storage_path: ~/.arcade
67
server:
78
address: ":3011"

handlers/webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func (h *WebhookHandler) deliverWebhook(ctx context.Context, sub models.Submissi
162162
slog.String("status", string(status.Status)))
163163

164164
status.StatusCode = http.StatusOK
165+
status.Title = "OK"
165166
payloadBytes, err := json.Marshal(status)
166167
if err != nil {
167168
h.logger.Error("Failed to marshal payload",

models/transaction.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ func (h *HexBytes) UnmarshalJSON(data []byte) error {
3939
type TransactionStatus struct {
4040
TxID string `json:"txid"`
4141
Status Status `json:"txStatus"`
42-
StatusCode int `json:"status,omitempty"`
42+
StatusCode int `json:"status"`
43+
Title string `json:"title"`
4344
Timestamp time.Time `json:"timestamp"`
4445
BlockHash string `json:"blockHash,omitempty"`
4546
BlockHeight uint64 `json:"blockHeight,omitempty"`
4647
MerklePath HexBytes `json:"merklePath,omitempty"`
4748
ExtraInfo string `json:"extraInfo,omitempty"`
48-
CompetingTxs []string `json:"competingTxs,omitempty"`
49+
CompetingTxs []string `json:"competingTxs"`
4950
CreatedAt time.Time `json:"-"`
5051
}
5152

routes/fiber/routes.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func (r *Routes) handlePostTx(c *fiber.Ctx) error {
128128
}
129129

130130
status.StatusCode = http.StatusOK
131+
status.Title = "OK"
131132
return c.JSON(status)
132133
}
133134

@@ -176,6 +177,7 @@ func (r *Routes) handlePostTxs(c *fiber.Ctx) error {
176177

177178
for _, s := range statuses {
178179
s.StatusCode = http.StatusOK
180+
s.Title = "OK"
179181
}
180182
return c.JSON(statuses)
181183
}
@@ -216,6 +218,7 @@ func (r *Routes) handleGetTx(c *fiber.Ctx) error {
216218
return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to get status"})
217219
}
218220
status.StatusCode = http.StatusOK
221+
status.Title = "OK"
219222
return c.JSON(status)
220223
}
221224

@@ -319,12 +322,13 @@ func (r *Routes) parseTransactionBody(c *fiber.Ctx) ([]byte, error) {
319322

320323
// extractSubmitOptions extracts SubmitOptions from HTTP headers.
321324
func (r *Routes) extractSubmitOptions(c *fiber.Ctx) *models.SubmitOptions {
325+
skipAll := c.Get("X-SkipTxValidation") == "true"
322326
return &models.SubmitOptions{
323327
CallbackURL: c.Get("X-CallbackUrl"),
324328
CallbackToken: c.Get("X-CallbackToken"),
325329
FullStatusUpdates: c.Get("X-FullStatusUpdates") == "true",
326-
SkipFeeValidation: c.Get("X-SkipFeeValidation") == "true",
327-
SkipScriptValidation: c.Get("X-SkipScriptValidation") == "true",
330+
SkipFeeValidation: skipAll || c.Get("X-SkipFeeValidation") == "true",
331+
SkipScriptValidation: skipAll || c.Get("X-SkipScriptValidation") == "true",
328332
}
329333
}
330334

0 commit comments

Comments
 (0)