diff --git a/lib/core/src/Cardano/Wallet.hs b/lib/core/src/Cardano/Wallet.hs index 91fb54f2690..fa73d598b8d 100644 --- a/lib/core/src/Cardano/Wallet.hs +++ b/lib/core/src/Cardano/Wallet.hs @@ -3066,8 +3066,9 @@ data BalanceTxNotSupportedReason deriving (Show, Eq) -- | Errors that can occur when submitting a transaction. -newtype ErrSubmitTransaction +data ErrSubmitTransaction = ErrSubmitTransactionNoSuchWallet ErrNoSuchWallet + | ErrSubmitTransactionForeignWallet deriving (Show, Eq) -- | Errors that can occur when constructing an unsigned transaction. diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index bc299e93291..b86e14fc3c3 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -3917,6 +3917,12 @@ instance IsServerError ErrSubmitTransaction where { errHTTPCode = 404 , errReasonPhrase = errReasonPhrase err404 } + ErrSubmitTransactionForeignWallet -> + apiError err403 ForeignTransaction $ mconcat + [ "The transaction to be submitted is foreign to the current wallet " + , "and cannot be sent. Submit a transaction that has either input, output " + , "or withdrawal belonging to the wallet." + ] instance IsServerError ErrSubmitTx where toServerError = \case diff --git a/lib/core/src/Cardano/Wallet/Api/Types.hs b/lib/core/src/Cardano/Wallet/Api/Types.hs index 2e6228f116f..02d62bd7c97 100644 --- a/lib/core/src/Cardano/Wallet/Api/Types.hs +++ b/lib/core/src/Cardano/Wallet/Api/Types.hs @@ -1662,6 +1662,7 @@ data ApiErrorCode | UnresolvedInputs | RedeemerInvalidData | ExistingKeyWitnesses + | ForeignTransaction deriving (Eq, Generic, Show, Data, Typeable) deriving anyclass NFData diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index e531bbf272b..4166aa8e792 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -4218,6 +4218,17 @@ x-errCreatedInvalidTransaction: &errCreatedInvalidTransaction type: string enum: ['created_invalid_transaction'] +x-errForeignTransaction: &errForeignTransaction + <<: *responsesErr + title: foreign_transaction + properties: + message: + type: string + description: Occurs when a transaction to be submitted does have neither input, output nor withdrawal belonging to a given wallet. + code: + type: string + enum: ['foreign_transaction'] + x-errRejectedByCoreNode: &errRejectedByCoreNode <<: *responsesErr title: rejected_by_core_node @@ -5116,6 +5127,13 @@ x-responsesSubmitTransaction: &responsesSubmitTransaction content: application/json: schema: *ApiTxId + 403: + description: Forbidden + content: + application/json: + schema: + oneOf: + - <<: *errForeignTransaction x-responsesPostExternalTransaction: &responsesPostExternalTransaction <<: *responsesErr400