Skip to content

Commit

Permalink
Merge pull request #455 from bitcoin-sv/feat/beef-swagger
Browse files Browse the repository at this point in the history
feat(BEEF): update beef error codes in swagger
  • Loading branch information
kuba-4chain authored Jun 10, 2024
2 parents 9362fe4 + 38102f7 commit 22e73d1
Show file tree
Hide file tree
Showing 8 changed files with 815 additions and 99 deletions.
142 changes: 142 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,9 @@ This endpoint is used to send a raw transaction to a miner for inclusion in the
|463|Unknown|Malformed transaction|[ErrorMalformed](#schemaerrormalformed)|
|464|Unknown|Invalid outputs|[ErrorOutputs](#schemaerroroutputs)|
|465|Unknown|Fee too low|[ErrorFee](#schemaerrorfee)|
|467|Unknown|Mined ancestors not found in BEEF|[ErrorMinedAncestorsNotFound](#schemaerrorminedancestorsnotfound)|
|468|Unknown|Invalid BUMPs in BEEF|[ErrorCalculatingMerkleRoots](#schemaerrorcalculatingmerkleroots)|
|469|Unknown|Invalid Merkle Roots|[ErrorValidatingMerkleRoots](#schemaerrorvalidatingmerkleroots)|

<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
Expand Down Expand Up @@ -1058,6 +1061,9 @@ This endpoint is used to send multiple raw transactions to a miner for inclusion
|463|Unknown|Malformed transaction|[ErrorMalformed](#schemaerrormalformed)|
|464|Unknown|Invalid outputs|[ErrorOutputs](#schemaerroroutputs)|
|465|Unknown|Fee too low|[ErrorFee](#schemaerrorfee)|
|467|Unknown|Mined ancestors not found in BEEF|[ErrorMinedAncestorsNotFound](#schemaerrorminedancestorsnotfound)|
|468|Unknown|Invalid BUMPs in BEEF|[ErrorCalculatingMerkleRoots](#schemaerrorcalculatingmerkleroots)|
|469|Unknown|Invalid Merkle Roots|[ErrorValidatingMerkleRoots](#schemaerrorvalidatingmerkleroots)|

<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
Expand Down Expand Up @@ -1530,6 +1536,24 @@ xor

xor

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|[ErrorMinedAncestorsNotFound](#schemaerrorminedancestorsnotfound)|false|none|none|

xor

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|[ErrorCalculatingMerkleRoots](#schemaerrorcalculatingmerkleroots)|false|none|none|

xor

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|[ErrorValidatingMerkleRoots](#schemaerrorvalidatingmerkleroots)|false|none|none|

xor

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|[ErrorFrozenPolicy](#schemaerrorfrozenpolicy)|false|none|none|
Expand Down Expand Up @@ -1930,6 +1954,123 @@ and
|» detail|any|false|none|none|
|» instance|any|false|none|none|

<h2 id="tocS_ErrorMinedAncestorsNotFound">ErrorMinedAncestorsNotFound</h2>
<!-- backwards compatibility -->
<a id="schemaerrorminedancestorsnotfound"></a>
<a id="schema_ErrorMinedAncestorsNotFound"></a>
<a id="tocSerrorminedancestorsnotfound"></a>
<a id="tocserrorminedancestorsnotfound"></a>

```json
{
"type": "https://bitcoin-sv.github.io/arc/#/errors?id=_467",
"title": "Mined ancestors not found",
"status": 467,
"detail": "Error validating BEEF: mined ancestors not found in transaction inputs",
"instance": "https://arc.taal.com/errors/123453",
"txid": "string",
"extraInfo": "string"
}

```

### Properties

allOf

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|[ErrorFields](#schemaerrorfields)|false|none|none|

and

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|object|false|none|none|
|» type|any|false|none|none|
|» title|any|false|none|none|
|» status|any|false|none|none|
|» detail|any|false|none|none|
|» instance|any|false|none|none|

<h2 id="tocS_ErrorCalculatingMerkleRoots">ErrorCalculatingMerkleRoots</h2>
<!-- backwards compatibility -->
<a id="schemaerrorcalculatingmerkleroots"></a>
<a id="schema_ErrorCalculatingMerkleRoots"></a>
<a id="tocSerrorcalculatingmerkleroots"></a>
<a id="tocserrorcalculatingmerkleroots"></a>

```json
{
"type": "https://bitcoin-sv.github.io/arc/#/errors?id=_468",
"title": "Invalid BUMPs",
"status": 468,
"detail": "Error validating BEEF: could not calculate Merkle Roots from given BUMPs",
"instance": "https://arc.taal.com/errors/123453",
"txid": "string",
"extraInfo": "string"
}

```

### Properties

allOf

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|[ErrorFields](#schemaerrorfields)|false|none|none|

and

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|object|false|none|none|
|» type|any|false|none|none|
|» title|any|false|none|none|
|» status|any|false|none|none|
|» detail|any|false|none|none|
|» instance|any|false|none|none|

<h2 id="tocS_ErrorValidatingMerkleRoots">ErrorValidatingMerkleRoots</h2>
<!-- backwards compatibility -->
<a id="schemaerrorvalidatingmerkleroots"></a>
<a id="schema_ErrorValidatingMerkleRoots"></a>
<a id="tocSerrorvalidatingmerkleroots"></a>
<a id="tocserrorvalidatingmerkleroots"></a>

```json
{
"type": "https://bitcoin-sv.github.io/arc/#/errors?id=_469",
"title": "Merkle Roots validation failed",
"status": 469,
"detail": "Error validating BEEF: could not validate Merkle Roots",
"instance": "https://arc.taal.com/errors/123453",
"txid": "string",
"extraInfo": "string"
}

```

### Properties

allOf

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|[ErrorFields](#schemaerrorfields)|false|none|none|

and

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|object|false|none|none|
|» type|any|false|none|none|
|» title|any|false|none|none|
|» status|any|false|none|none|
|» detail|any|false|none|none|
|» instance|any|false|none|none|

<h2 id="tocS_ErrorFrozenPolicy">ErrorFrozenPolicy</h2>
<!-- backwards compatibility -->
<a id="schemaerrorfrozenpolicy"></a>
Expand Down Expand Up @@ -2039,3 +2180,4 @@ and
|instance|string¦null|false|none|(Optional) Link to actual error on server|
|txid|string¦null|false|none|Transaction ID this error is referring to|
|extraInfo|string¦null|false|none|Optional extra information about the error from the miner|

153 changes: 153 additions & 0 deletions doc/arc.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,36 @@
}
}
}
},
"467": {
"description": "Mined ancestors not found in BEEF",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorMinedAncestorsNotFound"
}
}
}
},
"468": {
"description": "Invalid BUMPs in BEEF",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorCalculatingMerkleRoots"
}
}
}
},
"469": {
"description": "Invalid Merkle Roots",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorValidatingMerkleRoots"
}
}
}
}
}
}
Expand Down Expand Up @@ -526,6 +556,36 @@
}
}
}
},
"467": {
"description": "Mined ancestors not found in BEEF",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorMinedAncestorsNotFound"
}
}
}
},
"468": {
"description": "Invalid BUMPs in BEEF",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorCalculatingMerkleRoots"
}
}
}
},
"469": {
"description": "Invalid Merkle Roots",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorValidatingMerkleRoots"
}
}
}
}
}
}
Expand Down Expand Up @@ -902,6 +962,15 @@
{
"$ref": "#/components/schemas/ErrorMalformed"
},
{
"$ref": "#/components/schemas/ErrorMinedAncestorsNotFound"
},
{
"$ref": "#/components/schemas/ErrorCalculatingMerkleRoots"
},
{
"$ref": "#/components/schemas/ErrorValidatingMerkleRoots"
},
{
"$ref": "#/components/schemas/ErrorFrozenPolicy"
},
Expand Down Expand Up @@ -1190,6 +1259,90 @@
}
]
},
"ErrorMinedAncestorsNotFound": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/ErrorFields"
},
{
"type": "object",
"properties": {
"type": {
"example": "https://bitcoin-sv.github.io/arc/#/errors?id=_467"
},
"title": {
"example": "Mined ancestors not found"
},
"status": {
"example": 467
},
"detail": {
"example": "Error validating BEEF: mined ancestors not found in transaction inputs"
},
"instance": {
"example": "https://arc.taal.com/errors/123453"
}
}
}
]
},
"ErrorCalculatingMerkleRoots": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/ErrorFields"
},
{
"type": "object",
"properties": {
"type": {
"example": "https://bitcoin-sv.github.io/arc/#/errors?id=_468"
},
"title": {
"example": "Invalid BUMPs"
},
"status": {
"example": 468
},
"detail": {
"example": "Error validating BEEF: could not calculate Merkle Roots from given BUMPs"
},
"instance": {
"example": "https://arc.taal.com/errors/123453"
}
}
}
]
},
"ErrorValidatingMerkleRoots": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/ErrorFields"
},
{
"type": "object",
"properties": {
"type": {
"example": "https://bitcoin-sv.github.io/arc/#/errors?id=_469"
},
"title": {
"example": "Merkle Roots validation failed"
},
"status": {
"example": 469
},
"detail": {
"example": "Error validating BEEF: could not validate Merkle Roots"
},
"instance": {
"example": "https://arc.taal.com/errors/123453"
}
}
}
]
},
"ErrorFrozenPolicy": {
"type": "object",
"allOf": [
Expand Down
2 changes: 1 addition & 1 deletion internal/validator/default/default_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (v *DefaultValidator) ValidateBeef(beefTx *beef.BEEF, skipFeeValidation, sk
}

if err := beef.EnsureAncestorsArePresentInBump(beefTx.GetLatestTx(), beefTx); err != nil {
return validator.NewError(err, api.ErrBeefMinedAncestorsNotFound)
return validator.NewError(err, api.ErrStatusMinedAncestorsNotFound)
}

return nil
Expand Down
Loading

0 comments on commit 22e73d1

Please sign in to comment.